Autoformat py files using Black (#105)
* Autoformat all py files using Black
* Fix lint errors
* Fix indentation errors (https://travis-ci.org/httplib2/httplib2/jobs/408136309)
* Refactor three test cases and exclude them on on Travis py27/pypy
diff --git a/tests/test_encoding.py b/tests/test_encoding.py
index df991a1..c7eead5 100644
--- a/tests/test_encoding.py
+++ b/tests/test_encoding.py
@@ -6,42 +6,42 @@
# Test that we don't try to decompress a HEAD response
http = httplib2.Http()
response = tests.http_response_bytes(
- headers={'content-encoding': 'gzip', 'content-length': 42},
+ headers={"content-encoding": "gzip", "content-length": 42}
)
with tests.server_const_bytes(response) as uri:
- response, content = http.request(uri, 'HEAD')
+ response, content = http.request(uri, "HEAD")
assert response.status == 200
- assert int(response['content-length']) != 0
- assert content == b''
+ assert int(response["content-length"]) != 0
+ assert content == b""
def test_gzip_get():
# Test that we support gzip compression
http = httplib2.Http()
response = tests.http_response_bytes(
- headers={'content-encoding': 'gzip'},
- body=tests.gzip_compress(b'properly compressed'),
+ headers={"content-encoding": "gzip"},
+ body=tests.gzip_compress(b"properly compressed"),
)
with tests.server_const_bytes(response) as uri:
- response, content = http.request(uri, 'GET')
+ response, content = http.request(uri, "GET")
assert response.status == 200
- assert 'content-encoding' not in response
- assert '-content-encoding' in response
- assert int(response['content-length']) == len(b'properly compressed')
- assert content == b'properly compressed'
+ assert "content-encoding" not in response
+ assert "-content-encoding" in response
+ assert int(response["content-length"]) == len(b"properly compressed")
+ assert content == b"properly compressed"
def test_gzip_post_response():
http = httplib2.Http()
response = tests.http_response_bytes(
- headers={'content-encoding': 'gzip'},
- body=tests.gzip_compress(b'properly compressed'),
+ headers={"content-encoding": "gzip"},
+ body=tests.gzip_compress(b"properly compressed"),
)
with tests.server_const_bytes(response) as uri:
- response, content = http.request(uri, 'POST', body=b'')
+ response, content = http.request(uri, "POST", body=b"")
assert response.status == 200
- assert 'content-encoding' not in response
- assert '-content-encoding' in response
+ assert "content-encoding" not in response
+ assert "-content-encoding" in response
def test_gzip_malformed_response():
@@ -49,34 +49,33 @@
# Test that we raise a good exception when the gzip fails
http.force_exception_to_status_code = False
response = tests.http_response_bytes(
- headers={'content-encoding': 'gzip'},
- body=b'obviously not compressed',
+ headers={"content-encoding": "gzip"}, body=b"obviously not compressed"
)
with tests.server_const_bytes(response, request_count=2) as uri:
with tests.assert_raises(httplib2.FailedToDecompressContent):
- http.request(uri, 'GET')
+ http.request(uri, "GET")
# Re-run the test with out the exceptions
http.force_exception_to_status_code = True
- response, content = http.request(uri, 'GET')
+ response, content = http.request(uri, "GET")
assert response.status == 500
- assert response.reason.startswith('Content purported')
+ assert response.reason.startswith("Content purported")
def test_deflate_get():
# Test that we support deflate compression
http = httplib2.Http()
response = tests.http_response_bytes(
- headers={'content-encoding': 'deflate'},
- body=tests.deflate_compress(b'properly compressed'),
+ headers={"content-encoding": "deflate"},
+ body=tests.deflate_compress(b"properly compressed"),
)
with tests.server_const_bytes(response) as uri:
- response, content = http.request(uri, 'GET')
+ response, content = http.request(uri, "GET")
assert response.status == 200
- assert 'content-encoding' not in response
- assert int(response['content-length']) == len(b'properly compressed')
- assert content == b'properly compressed'
+ assert "content-encoding" not in response
+ assert int(response["content-length"]) == len(b"properly compressed")
+ assert content == b"properly compressed"
def test_deflate_malformed_response():
@@ -84,16 +83,15 @@
http = httplib2.Http()
http.force_exception_to_status_code = False
response = tests.http_response_bytes(
- headers={'content-encoding': 'deflate'},
- body=b'obviously not compressed',
+ headers={"content-encoding": "deflate"}, body=b"obviously not compressed"
)
with tests.server_const_bytes(response, request_count=2) as uri:
with tests.assert_raises(httplib2.FailedToDecompressContent):
- http.request(uri, 'GET')
+ http.request(uri, "GET")
# Re-run the test with out the exceptions
http.force_exception_to_status_code = True
- response, content = http.request(uri, 'GET')
+ response, content = http.request(uri, "GET")
assert response.status == 500
- assert response.reason.startswith('Content purported')
+ assert response.reason.startswith("Content purported")