From 64ccc02c92db3a0f3da9323fafe668658cf60d0c Mon Sep 17 00:00:00 2001 From: Jean-Paul Calderone Date: Mon, 23 Apr 2018 08:10:20 -0400 Subject: [PATCH 1/4] Add the docs --- src/twisted/web/static.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/twisted/web/static.py b/src/twisted/web/static.py index 575570a9c1a..fdc7b6dc70d 100644 --- a/src/twisted/web/static.py +++ b/src/twisted/web/static.py @@ -51,6 +51,14 @@ class Data(resource.Resource): """ def __init__(self, data, type): + """ + @param data: The bytes that make up this data resource. + @type data: L{bytes} + + @param type: A native string giving the Internet media type for this + content. + @type type: L{str} + """ resource.Resource.__init__(self) self.data = data self.type = type From f56aff5eaddd98eac990a09689889531a92b23dc Mon Sep 17 00:00:00 2001 From: Jean-Paul Calderone Date: Mon, 23 Apr 2018 08:11:03 -0400 Subject: [PATCH 2/4] news fragment --- src/twisted/web/newsfragments/9432.misc | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 src/twisted/web/newsfragments/9432.misc diff --git a/src/twisted/web/newsfragments/9432.misc b/src/twisted/web/newsfragments/9432.misc new file mode 100644 index 00000000000..e69de29bb2d From 1b9863b6f2c39a96581bbd25e3c60e8ebf391bfc Mon Sep 17 00:00:00 2001 From: Mark Williams Date: Sun, 6 May 2018 12:47:39 -0700 Subject: [PATCH 3/4] test_closePeerOnEMFILE allows ConnectionLost on client's end. Whether the client's connectionLost method is called with ConnectionDone or ConnectionLost depends on its internal state, which the test cannot directly control; for example, a TLS handshake might not have completed by the time the server disconnects the client. Make the test more robust by allowing both ConnectionDone and ConnectionLost. --- src/twisted/internet/test/test_tcp.py | 3 +-- src/twisted/newsfragments/9439.misc | 0 2 files changed, 1 insertion(+), 2 deletions(-) create mode 100644 src/twisted/newsfragments/9439.misc diff --git a/src/twisted/internet/test/test_tcp.py b/src/twisted/internet/test/test_tcp.py index fc99d6b22fb..22055ad1add 100644 --- a/src/twisted/internet/test/test_tcp.py +++ b/src/twisted/internet/test/test_tcp.py @@ -1266,7 +1266,7 @@ def stopReactorAndCloseFileDescriptors(result): testCase.assertNoResult(clientFactory.failDeferred) testCase.successResultOf(clientFactory.deferred) testCase.assertRaises( - testCase.lostConnectionReason, + (ConnectionDone, ConnectionLost), clientFactory.lostReason.raiseException, ) @@ -1357,7 +1357,6 @@ class StreamTransportTestsMixin(LogObserverMixin): """ Mixin defining tests which apply to any port/connection based transport. """ - lostConnectionReason = ConnectionDone def test_startedListeningLogMessage(self): """ diff --git a/src/twisted/newsfragments/9439.misc b/src/twisted/newsfragments/9439.misc new file mode 100644 index 00000000000..e69de29bb2d From b3407a51345f2c351862a98290ac134b3e34417d Mon Sep 17 00:00:00 2001 From: Mark Williams Date: Sun, 6 May 2018 19:21:43 -0700 Subject: [PATCH 4/4] Use the super type of both ConnectionDone and ConnectionLost. Thanks, @exakrun! --- src/twisted/internet/test/test_tcp.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/twisted/internet/test/test_tcp.py b/src/twisted/internet/test/test_tcp.py index 22055ad1add..515d708cea3 100644 --- a/src/twisted/internet/test/test_tcp.py +++ b/src/twisted/internet/test/test_tcp.py @@ -33,7 +33,7 @@ from twisted.internet.error import ( ConnectionLost, UserError, ConnectionRefusedError, ConnectionDone, ConnectionAborted, DNSLookupError, NoProtocol, - ConnectBindError, + ConnectBindError, ConnectionClosed, ) from twisted.internet.test.connectionmixins import ( LogObserverMixin, ConnectionTestsMixin, StreamClientTestsMixin, @@ -1266,7 +1266,7 @@ def stopReactorAndCloseFileDescriptors(result): testCase.assertNoResult(clientFactory.failDeferred) testCase.successResultOf(clientFactory.deferred) testCase.assertRaises( - (ConnectionDone, ConnectionLost), + ConnectionClosed, clientFactory.lostReason.raiseException, )