Xqt submitted this change.
[tests] Test header with fetch
Also use context manager to close the session, available since 0.6.0
Change-Id: I76f8c3cef22fe0178a0cd509b9cf05076eb9f781
---
M tests/http_tests.py
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/tests/http_tests.py b/tests/http_tests.py
index 2bd4256..b346ceb 100644
--- a/tests/http_tests.py
+++ b/tests/http_tests.py
@@ -516,18 +516,17 @@
def test_requests(self):
"""Test with requests, underlying package."""
- s = requests.Session()
- r = s.get(self.url)
+ with requests.Session() as s:
+ r = s.get(self.url)
- self.assertEqual(r.headers['content-type'], 'image/png')
- self.assertEqual(r.content, self.png)
-
- s.close()
+ self.assertEqual(r.headers['content-type'], 'image/png')
+ self.assertEqual(r.content, self.png)
def test_http(self):
"""Test with http, standard http interface for pywikibot."""
r = http.fetch(self.url)
+ self.assertEqual(r.headers['content-type'], 'image/png')
self.assertEqual(r.content, self.png)
To view, visit change 703216. To unsubscribe, or for help writing mail filters, visit settings.