From 2c98a88a0e584fff64eb70f48b869494eca1d7ae Mon Sep 17 00:00:00 2001 From: Joakim Uddholm Date: Sun, 12 Jun 2016 10:49:34 +0200 Subject: [PATCH] Separated tests based on case --- tests/test_utils_gz.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/tests/test_utils_gz.py b/tests/test_utils_gz.py index e107615f3..3648d5c43 100644 --- a/tests/test_utils_gz.py +++ b/tests/test_utils_gz.py @@ -29,15 +29,24 @@ class GunzipTest(unittest.TestCase): text = gunzip(f.read()) assert text.endswith(b'') - def test_is_gzipped(self): + def test_is_gzipped_right(self): hdrs = Headers({"Content-Type": "application/x-gzip"}) r1 = Response("http://www.example.com", headers=hdrs) self.assertTrue(is_gzipped(r1)) - r2 = Response("http://www.example.com") - self.assertTrue(not is_gzipped(r2)) + hdrs = Headers({"Content-Type": "application/gzip"}) + r1 = Response("http://www.example.com", headers=hdrs) + self.assertTrue(is_gzipped(r1)) + + def test_is_gzipped_empty(self): + r1 = Response("http://www.example.com") + self.assertTrue(not is_gzipped(r1)) + + def test_is_gzipped_wrong(self): hdrs = Headers({"Content-Type": "application/javascript"}) - r3 = Response("http://www.example.com", headers=hdrs) - self.assertTrue(not is_gzipped(r3)) + r1 = Response("http://www.example.com", headers=hdrs) + self.assertTrue(not is_gzipped(r1)) + + def test_is_gzipped_with_charset(self): hdrs = Headers({"Content-Type": "application/x-gzip;charset=utf-8"}) r1 = Response("http://www.example.com", headers=hdrs) self.assertTrue(is_gzipped(r1))