summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorYury Selivanov <yselivanov@sprymix.com>2016-05-13 20:05:05 (GMT)
committerYury Selivanov <yselivanov@sprymix.com>2016-05-13 20:05:05 (GMT)
commit2e413f7cc7d54f2af77b0242605cf3c8adc26a6f (patch)
tree11e326fdcaaa8199a853fb37dfdf53afdf1d5ab9 /Lib/test
parent8308db5cd56f0a3ec33759bf482563be37bcd648 (diff)
parent5dc093336f6f6c7bd0b79c1c870dc9b733fc2fe5 (diff)
downloadcpython-2e413f7cc7d54f2af77b0242605cf3c8adc26a6f.zip
cpython-2e413f7cc7d54f2af77b0242605cf3c8adc26a6f.tar.gz
cpython-2e413f7cc7d54f2af77b0242605cf3c8adc26a6f.tar.bz2
Merge 3.5 (asyncio)
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_asyncio/test_events.py35
1 files changed, 35 insertions, 0 deletions
diff --git a/Lib/test/test_asyncio/test_events.py b/Lib/test/test_asyncio/test_events.py
index 4b4e3c0..d52213c 100644
--- a/Lib/test/test_asyncio/test_events.py
+++ b/Lib/test/test_asyncio/test_events.py
@@ -1368,6 +1368,41 @@ class EventLoopTestsMixin:
@unittest.skipUnless(sys.platform != 'win32',
"Don't support pipes for Windows")
+ def test_unclosed_pipe_transport(self):
+ # This test reproduces the issue #314 on GitHub
+ loop = self.create_event_loop()
+ read_proto = MyReadPipeProto(loop=loop)
+ write_proto = MyWritePipeProto(loop=loop)
+
+ rpipe, wpipe = os.pipe()
+ rpipeobj = io.open(rpipe, 'rb', 1024)
+ wpipeobj = io.open(wpipe, 'w', 1024)
+
+ @asyncio.coroutine
+ def connect():
+ read_transport, _ = yield from loop.connect_read_pipe(
+ lambda: read_proto, rpipeobj)
+ write_transport, _ = yield from loop.connect_write_pipe(
+ lambda: write_proto, wpipeobj)
+ return read_transport, write_transport
+
+ # Run and close the loop without closing the transports
+ read_transport, write_transport = loop.run_until_complete(connect())
+ loop.close()
+
+ # These 'repr' calls used to raise an AttributeError
+ # See Issue #314 on GitHub
+ self.assertIn('open', repr(read_transport))
+ self.assertIn('open', repr(write_transport))
+
+ # Clean up (avoid ResourceWarning)
+ rpipeobj.close()
+ wpipeobj.close()
+ read_transport._pipe = None
+ write_transport._pipe = None
+
+ @unittest.skipUnless(sys.platform != 'win32',
+ "Don't support pipes for Windows")
# select, poll and kqueue don't support character devices (PTY) on Mac OS X
# older than 10.6 (Snow Leopard)
@support.requires_mac_ver(10, 6)