summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrendan McCollam <bmccollam@uchicago.edu>2017-05-02 13:47:12 +0100
committerBrendan McCollam <bmccollam@uchicago.edu>2017-05-02 14:03:09 +0100
commitc8953ea44be1aa30d314e1edd833babc2297bbc6 (patch)
treed065fb839b1bc66412245b13069b91c6e2f17d4e
parent435a1cf4285d61208698270c314ac42632b1ae16 (diff)
downloadwebtest-c8953ea44be1aa30d314e1edd833babc2297bbc6.tar.gz
Improves testing of check_headers
Adds new tests for: - unicode headers in Py2 - bytes headers in Py3 Updates existing non-latin1 tests to run in both Py2 and Py3.
-rw-r--r--tests/test_lint.py32
1 files changed, 26 insertions, 6 deletions
diff --git a/tests/test_lint.py b/tests/test_lint.py
index 2cb1e9a..6f2a963 100644
--- a/tests/test_lint.py
+++ b/tests/test_lint.py
@@ -143,13 +143,33 @@ class TestCheckContentType(unittest.TestCase):
class TestCheckHeaders(unittest.TestCase):
- @unittest.skipIf(not PY3, 'Useless in Python2')
- def test_header_unicode_value(self):
- self.assertRaises(AssertionError, check_headers, [('X-Price', '100€')])
-
- @unittest.skipIf(not PY3, 'Useless in Python2')
+ @unittest.skipIf(PY3, 'unicode is str in Python3')
def test_header_unicode_name(self):
- self.assertRaises(AssertionError, check_headers, [('X-€', 'foo')])
+ headers = [(u'X-Price', str('100'))]
+ self.assertRaises(AssertionError, check_headers, headers)
+
+ @unittest.skipIf(PY3, 'unicode is str in Python3')
+ def test_header_unicode_value(self):
+ headers = [(str('X-Price'), u'100')]
+ self.assertRaises(AssertionError, check_headers, headers)
+
+ @unittest.skipIf(not PY3, 'bytes is str in Python2')
+ def test_header_bytes_name(self):
+ headers = [(b'X-Price', '100')]
+ self.assertRaises(AssertionError, check_headers, headers)
+
+ @unittest.skipIf(not PY3, 'bytes is str in Python2')
+ def test_header_bytes_value(self):
+ headers = [('X-Price', b'100')]
+ self.assertRaises(AssertionError, check_headers, headers)
+
+ def test_header_non_latin1_value(self):
+ headers = [(str('X-Price'), '100€')]
+ self.assertRaises(AssertionError, check_headers, headers)
+
+ def test_header_non_latin1_name(self):
+ headers = [('X-€', str('foo'))]
+ self.assertRaises(AssertionError, check_headers, headers)
class TestCheckEnviron(unittest.TestCase):