summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2015-01-14 22:58:14 +0100
committerVictor Stinner <victor.stinner@gmail.com>2015-01-14 22:58:14 +0100
commit3d5d99c4a3bbcedb1e338cdc3daa33aa0d09a122 (patch)
tree25edbb65a78da6e1f80c44ab5bd1a4e091733dc2
parentafcc57eb7b911ec1e9b70787cf2730c7b5bd9c21 (diff)
downloadtrollius-3d5d99c4a3bbcedb1e338cdc3daa33aa0d09a122.tar.gz
Tests: explicitly close event loops and transports
-rw-r--r--tests/test_base_events.py1
-rw-r--r--tests/test_events.py5
-rw-r--r--tests/test_futures.py1
-rw-r--r--tests/test_selector_events.py1
-rw-r--r--tests/test_unix_events.py1
5 files changed, 9 insertions, 0 deletions
diff --git a/tests/test_base_events.py b/tests/test_base_events.py
index 6bf7e79..bd6c0d8 100644
--- a/tests/test_base_events.py
+++ b/tests/test_base_events.py
@@ -409,6 +409,7 @@ class BaseEventLoopTests(test_utils.TestCase):
def test_run_until_complete_loop(self):
task = asyncio.Future(loop=self.loop)
other_loop = self.new_test_loop()
+ self.addCleanup(other_loop.close)
self.assertRaises(ValueError,
other_loop.run_until_complete, task)
diff --git a/tests/test_events.py b/tests/test_events.py
index a2c6dc9..d40c8e4 100644
--- a/tests/test_events.py
+++ b/tests/test_events.py
@@ -1585,6 +1585,7 @@ class SubprocessTestsMixin:
self.assertTrue(all(f.done() for f in proto.disconnects.values()))
self.assertEqual(proto.data[1].rstrip(b'\r\n'), b'Python')
self.assertEqual(proto.data[2], b'')
+ transp.close()
def test_subprocess_exitcode(self):
connect = self.loop.subprocess_shell(
@@ -1594,6 +1595,7 @@ class SubprocessTestsMixin:
self.assertIsInstance(proto, MySubprocessProtocol)
self.loop.run_until_complete(proto.completed)
self.assertEqual(7, proto.returncode)
+ transp.close()
def test_subprocess_close_after_finish(self):
connect = self.loop.subprocess_shell(
@@ -1621,6 +1623,7 @@ class SubprocessTestsMixin:
transp.kill()
self.loop.run_until_complete(proto.completed)
self.check_killed(proto.returncode)
+ transp.close()
def test_subprocess_terminate(self):
prog = os.path.join(os.path.dirname(__file__), 'echo.py')
@@ -1635,6 +1638,7 @@ class SubprocessTestsMixin:
transp.terminate()
self.loop.run_until_complete(proto.completed)
self.check_terminated(proto.returncode)
+ transp.close()
@unittest.skipIf(sys.platform == 'win32', "Don't have SIGHUP")
def test_subprocess_send_signal(self):
@@ -1650,6 +1654,7 @@ class SubprocessTestsMixin:
transp.send_signal(signal.SIGHUP)
self.loop.run_until_complete(proto.completed)
self.assertEqual(-signal.SIGHUP, proto.returncode)
+ transp.close()
def test_subprocess_stderr(self):
prog = os.path.join(os.path.dirname(__file__), 'echo2.py')
diff --git a/tests/test_futures.py b/tests/test_futures.py
index dac1e89..c8b6829 100644
--- a/tests/test_futures.py
+++ b/tests/test_futures.py
@@ -29,6 +29,7 @@ class FutureTests(test_utils.TestCase):
def setUp(self):
self.loop = self.new_test_loop()
+ self.addCleanup(self.loop.close)
def test_initial_state(self):
f = asyncio.Future(loop=self.loop)
diff --git a/tests/test_selector_events.py b/tests/test_selector_events.py
index 64c2e65..3e8392e 100644
--- a/tests/test_selector_events.py
+++ b/tests/test_selector_events.py
@@ -1744,6 +1744,7 @@ class SelectorDatagramTransportTests(test_utils.TestCase):
test_utils.MockPattern(
'Fatal error on transport\nprotocol:.*\ntransport:.*'),
exc_info=(ConnectionRefusedError, MOCK_ANY, MOCK_ANY))
+ transport.close()
if __name__ == '__main__':
diff --git a/tests/test_unix_events.py b/tests/test_unix_events.py
index 4b825dc..5f4b024 100644
--- a/tests/test_unix_events.py
+++ b/tests/test_unix_events.py
@@ -598,6 +598,7 @@ class UnixWritePipeTransportTests(test_utils.TestCase):
# This is a bit overspecified. :-(
m_log.warning.assert_called_with(
'pipe closed by peer or os.write(pipe, data) raised exception.')
+ tr.close()
@mock.patch('os.write')
def test_write_close(self, m_write):