From 101e1c17b1b9b0616f82bf6af8d9b0c704f4a15f Mon Sep 17 00:00:00 2001 From: David Wilson Date: Wed, 23 Jan 2019 12:44:08 +0000 Subject: [PATCH] issue #477: stop using fork() in parent_test, compatible enumerate(). --- tests/parent_test.py | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/tests/parent_test.py b/tests/parent_test.py index 325ca8fc..00bddb4d 100644 --- a/tests/parent_test.py +++ b/tests/parent_test.py @@ -138,7 +138,7 @@ class StreamErrorTest(testlib.RouterMixin, testlib.TestCase): def test_via_eof(self): # Verify FD leakage does not keep failed process open. - local = self.router.fork() + local = self.router.local() e = self.assertRaises(mitogen.core.StreamError, lambda: self.router.local( via=local, @@ -160,7 +160,7 @@ class StreamErrorTest(testlib.RouterMixin, testlib.TestCase): self.assertTrue(e.args[0].startswith(prefix)) def test_via_enoent(self): - local = self.router.fork() + local = self.router.local() e = self.assertRaises(mitogen.core.StreamError, lambda: self.router.local( via=local, @@ -265,9 +265,9 @@ class IterReadTest(testlib.TestCase): proc = self.make_proc() try: reader = self.func([proc.stdout.fileno()]) - for i, chunk in enumerate(reader, 1): - self.assertEqual(i, int(chunk)) - if i > 3: + for i, chunk in enumerate(reader): + self.assertEqual(1+i, int(chunk)) + if i > 2: break finally: Popen__terminate(proc) @@ -358,7 +358,7 @@ class DisconnectTest(testlib.RouterMixin, testlib.TestCase): def test_child_disconnected(self): # Easy mode: process notices its own directly connected child is # disconnected. - c1 = self.router.fork() + c1 = self.router.local() recv = c1.call_async(time.sleep, 9999) c1.shutdown(wait=True) e = self.assertRaises(mitogen.core.ChannelError, @@ -368,8 +368,8 @@ class DisconnectTest(testlib.RouterMixin, testlib.TestCase): def test_indirect_child_disconnected(self): # Achievement unlocked: process notices an indirectly connected child # is disconnected. - c1 = self.router.fork() - c2 = self.router.fork(via=c1) + c1 = self.router.local() + c2 = self.router.local(via=c1) recv = c2.call_async(time.sleep, 9999) c2.shutdown(wait=True) e = self.assertRaises(mitogen.core.ChannelError, @@ -379,8 +379,8 @@ class DisconnectTest(testlib.RouterMixin, testlib.TestCase): def test_indirect_child_intermediary_disconnected(self): # Battlefield promotion: process notices indirect child disconnected # due to an intermediary child disconnecting. - c1 = self.router.fork() - c2 = self.router.fork(via=c1) + c1 = self.router.local() + c2 = self.router.local(via=c1) recv = c2.call_async(time.sleep, 9999) c1.shutdown(wait=True) e = self.assertRaises(mitogen.core.ChannelError, @@ -390,8 +390,8 @@ class DisconnectTest(testlib.RouterMixin, testlib.TestCase): def test_near_sibling_disconnected(self): # Hard mode: child notices sibling connected to same parent has # disconnected. - c1 = self.router.fork() - c2 = self.router.fork() + c1 = self.router.local() + c2 = self.router.local() # Let c1 call functions in c2. self.router.stream_by_id(c1.context_id).auth_id = mitogen.context_id @@ -412,11 +412,11 @@ class DisconnectTest(testlib.RouterMixin, testlib.TestCase): def test_far_sibling_disconnected(self): # God mode: child of child notices child of child of parent has # disconnected. - c1 = self.router.fork() - c11 = self.router.fork(via=c1) + c1 = self.router.local() + c11 = self.router.local(via=c1) - c2 = self.router.fork() - c22 = self.router.fork(via=c2) + c2 = self.router.local() + c22 = self.router.local(via=c2) # Let c1 call functions in c2. self.router.stream_by_id(c1.context_id).auth_id = mitogen.context_id