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.
This commit is contained in:
David Wilson 2018-05-28 02:34:12 +01:00
parent dd48c41332
commit 633585524f
2 changed files with 11 additions and 13 deletions

View File

@ -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()

View File

@ -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