diff options
author | Victor Stinner <vstinner@redhat.com> | 2015-07-20 17:18:59 +0200 |
---|---|---|
committer | Victor Stinner <vstinner@redhat.com> | 2015-07-20 17:36:41 +0200 |
commit | 13b71a16ee9d5af4939a7e214e92fa89cb96f6a3 (patch) | |
tree | cb9525ce018206804591e7e255c5745a044018c6 /tests/test_streams.py | |
parent | 9bb67431adc916d9d4b4e23ca257658c980d035d (diff) | |
download | trollius-git-closing.tar.gz |
Add closing read-only property to transportsclosing
* Disallow write() on closing transports
* Disallow aslo calling pause_writing() and resume_writing() on
StreamReaderProtocol if the transport is closing
Diffstat (limited to 'tests/test_streams.py')
-rw-r--r-- | tests/test_streams.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/test_streams.py b/tests/test_streams.py index 242b377..c883ba3 100644 --- a/tests/test_streams.py +++ b/tests/test_streams.py @@ -636,6 +636,23 @@ os.close(fd) protocol = asyncio.StreamReaderProtocol(reader) self.assertIs(protocol._loop, self.loop) + def test_pause_writing_closing(self): + reader = mock.Mock() + transport = asyncio.ReadTransport() + protocol = asyncio.StreamReaderProtocol(reader, loop=self.loop) + protocol.connection_made(transport) + transport._closing = True + self.assertRaises(RuntimeError, protocol.pause_writing) + + def test_resume_writing_closing(self): + reader = mock.Mock() + transport = asyncio.ReadTransport() + protocol = asyncio.StreamReaderProtocol(reader, loop=self.loop) + protocol.connection_made(transport) + protocol.pause_writing() + transport._closing = True + self.assertRaises(RuntimeError, protocol.resume_writing) + if __name__ == '__main__': unittest.main() |