diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2015-01-15 14:23:32 +0100 |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2015-01-15 14:23:32 +0100 |
commit | e70e384fcebeb63a4fc0e690e47b4d24437a5c95 (patch) | |
tree | c6df21a9782454335fb4d4d812a32b0d063b1997 /tests/test_windows_utils.py | |
parent | 180ea50b9a83de00713f8a4ecd1a91ed080968ac (diff) | |
download | trollius-e70e384fcebeb63a4fc0e690e47b4d24437a5c95.tar.gz |
Close transports in tests
* Use test_utils.run_briefly() to execute pending calls to really close
transports
* sslproto: mock also _SSLPipe.shutdown(), it's need to close the transport
* pipe test: the test doesn't close explicitly the PipeHandle, so ignore
the warning instead
* test_popen: use the context manager ("with p:") to explicitly close pipes
Diffstat (limited to 'tests/test_windows_utils.py')
-rw-r--r-- | tests/test_windows_utils.py | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/tests/test_windows_utils.py b/tests/test_windows_utils.py index af5c453..d48b8bc 100644 --- a/tests/test_windows_utils.py +++ b/tests/test_windows_utils.py @@ -3,6 +3,7 @@ import socket import sys import unittest +import warnings from unittest import mock if sys.platform != 'win32': @@ -115,8 +116,10 @@ class PipeTests(unittest.TestCase): self.assertEqual(p.handle, h) # check garbage collection of p closes handle - del p - support.gc_collect() + with warnings.catch_warnings(): + warnings.filterwarnings("ignore", "", ResourceWarning) + del p + support.gc_collect() try: _winapi.CloseHandle(h) except OSError as e: @@ -170,7 +173,9 @@ class PopenTests(unittest.TestCase): self.assertTrue(msg.upper().rstrip().startswith(out)) self.assertTrue(b"stderr".startswith(err)) - p.wait() + # The context manager calls wait() and closes resources + with p: + pass if __name__ == '__main__': |