Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
More tests
  • Loading branch information
Yury Selivanov
Yury Selivanov committed May 29, 2018
commit 0bd8ecbd8cc3ab15b8a54af47c32fc9da7113b06
17 changes: 14 additions & 3 deletions Lib/test/test_asyncio/test_unix_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -1811,18 +1811,29 @@ def setUp(self):
asyncio.set_event_loop(self.parent_loop)
self.ctx = multiprocessing.get_context("fork")

def tearDown(self):
self.parent_loop.close()

def _check_loops_not_equal(self, old_loop):
loop = asyncio.get_event_loop()
if loop is old_loop:
raise RuntimeError("Child process inherited parent's event loop")

try:
val = loop.run_until_complete(asyncio.sleep(0.05, result=42))
if val != 42:
raise RuntimeError("new event loop does not work")
finally:
loop.close()

sys.exit(loop is old_loop)

def test_new_loop_in_child(self):
p = self.ctx.Process(target=self._check_loops_not_equal,
args=(self.parent_loop,))
p.start()
p.join()
self.assertEqual(p.exitcode, 0,
"Child process inherited parent's event loop")
self.parent_loop.close()
self.assertEqual(p.exitcode, 0)


class PolicyTests(unittest.TestCase):
Expand Down