From 633585524f9b162f007e206491279104996bca56 Mon Sep 17 00:00:00 2001 From: David Wilson Date: Mon, 28 May 2018 02:34:12 +0100 Subject: [PATCH] tests: don't need separate module for id_allocation_test any more This used to be because everything would explode while importing __main__ under py.test, but that was fixed months ago. --- tests/data/id_allocation.py | 10 ---------- tests/id_allocation_test.py | 14 +++++++++++--- 2 files changed, 11 insertions(+), 13 deletions(-) delete mode 100644 tests/data/id_allocation.py diff --git a/tests/data/id_allocation.py b/tests/data/id_allocation.py deleted file mode 100644 index c9aa64b0..00000000 --- a/tests/data/id_allocation.py +++ /dev/null @@ -1,10 +0,0 @@ - -import mitogen.core -import mitogen.parent - - -@mitogen.core.takes_econtext -def allocate_an_id(econtext): - mitogen.parent.upgrade_router(econtext) - return econtext.router.allocate_id() - diff --git a/tests/id_allocation_test.py b/tests/id_allocation_test.py index 2d2c38f7..1e8d8d1e 100644 --- a/tests/id_allocation_test.py +++ b/tests/id_allocation_test.py @@ -2,7 +2,15 @@ import unittest2 import testlib -import id_allocation + +import mitogen.core +import mitogen.parent + + +@mitogen.core.takes_econtext +def allocate_an_id(econtext): + mitogen.parent.upgrade_router(econtext) + return econtext.router.allocate_id() class SlaveTest(testlib.RouterMixin, testlib.TestCase): @@ -12,11 +20,11 @@ class SlaveTest(testlib.RouterMixin, testlib.TestCase): self.assertEquals(1, context.context_id) # First call from slave allocates a block (2..1001) - id_ = context.call(id_allocation.allocate_an_id) + id_ = context.call(allocate_an_id) self.assertEqual(id_, 2) # Second call from slave allocates from block (3..1001) - id_ = context.call(id_allocation.allocate_an_id) + id_ = context.call(allocate_an_id) self.assertEqual(id_, 3) # Subsequent master allocation does not collide