From 411ef48e5bca1ed66a2e4dd7ecd8695e2bf6c94e Mon Sep 17 00:00:00 2001 From: Tim Burke Date: Fri, 22 Jun 2018 16:49:03 -0700 Subject: Stop leaking quite so many connections While investigating the failures when you move func tests to py3, I noticed a whole bunch of ResourceWarning: unclosed noise. This should fix it. While we're at it, make get_capabilities less stupid. Change-Id: I3913e9334090b04a78143e0b70f621aad30fc642 Related-Change: I86d24104033b490a35178fc504d88c1e4a566628 --- tests/unit/test_swiftclient.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'tests/unit/test_swiftclient.py') diff --git a/tests/unit/test_swiftclient.py b/tests/unit/test_swiftclient.py index f114774..62875a5 100644 --- a/tests/unit/test_swiftclient.py +++ b/tests/unit/test_swiftclient.py @@ -2532,6 +2532,9 @@ class TestConnection(MockHttpTest): def read(self, *args, **kwargs): return '' + def close(self): + pass + def local_http_connection(url, proxy=None, cacert=None, insecure=False, cert=None, cert_key=None, ssl_compression=True, timeout=None): @@ -2901,6 +2904,9 @@ class TestCloseConnection(MockHttpTest): self.assertIsNone(conn.http_conn) conn.close() self.assertIsNone(conn.http_conn) + # Can re-close + conn.close() + self.assertIsNone(conn.http_conn) def test_close_ok(self): url = 'http://www.test.com' @@ -2911,7 +2917,7 @@ class TestCloseConnection(MockHttpTest): self.assertEqual(len(conn.http_conn), 2) http_conn_obj = conn.http_conn[1] self.assertIsInstance(http_conn_obj, c.HTTPConnection) - self.assertFalse(hasattr(http_conn_obj, 'close')) + self.assertTrue(hasattr(http_conn_obj, 'close')) conn.close() -- cgit v1.2.1