summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArthur Vuillard <arthur.vuillard@gmail.com>2013-02-22 12:39:09 +0100
committerArthur Vuillard <arthur.vuillard@gmail.com>2013-02-22 12:39:09 +0100
commit3298f4feda5e921fff4a6903c1e11da19bf16f7a (patch)
treea298473d72c0b83040bb1aca41d2e45700a1cece
parentd0db4b924d70471856f3dcd37f9388f1f43bc5ca (diff)
downloadwebtest-3298f4feda5e921fff4a6903c1e11da19bf16f7a.tar.gz
Make test of check_content_type really unit tests
-rw-r--r--tests/test_lint.py55
1 files changed, 22 insertions, 33 deletions
diff --git a/tests/test_lint.py b/tests/test_lint.py
index f70d124..15720fd 100644
--- a/tests/test_lint.py
+++ b/tests/test_lint.py
@@ -7,6 +7,11 @@ import webtest
from webob import Request, Response
+from webtest.lint import check_headers
+from webtest.lint import check_content_type
+
+from six import PY3
+
def application(environ, start_response):
req = Request(environ)
@@ -24,34 +29,21 @@ def application(environ, start_response):
return resp(environ, start_response)
-def no_content_with_content(environ, start_response):
- status = "204 No Content"
- body = 'truc'
- headers = [
- ('Content-Type', 'text/plain; charset=utf-8'),
- ('Content-Length', str(len(body)))]
- start_response(status, headers)
- return [body]
-
-
-def no_content_type(environ, start_response):
- status = "200 OK"
- body = 'truc'
- headers = [
- #('Content-Type', 'text/plain; charset=utf-8'),
- ('Content-Length', str(len(body)))]
- start_response(status, headers)
- return [body]
-
-
-class TestForms(unittest.TestCase):
+class TestCheckContentType(unittest.TestCase):
def test_no_content(self):
- app = webtest.TestApp(no_content_with_content)
- self.assertRaises(AssertionError, app.get, '/')
+ status = "204 No Content"
+ headers = [
+ ('Content-Type', 'text/plain; charset=utf-8'),
+ ('Content-Length', '4')
+ ]
+ self.assertRaises(AssertionError, check_content_type, status, headers)
def test_no_content_type(self):
- app = webtest.TestApp(no_content_type)
- self.assertRaises(AssertionError, app.get, '/')
+ status = "200 OK"
+ headers = [
+ ('Content-Length', '4')
+ ]
+ self.assertRaises(AssertionError, check_content_type, status, headers)
class TestInputWrapper(unittest.TestCase):
@@ -70,16 +62,13 @@ class TestInputWrapper(unittest.TestCase):
resp = app.post('/read_lines', 'hello\nt\n')
self.assertEqual(resp.body, b'hello\n-t\n')
-from webtest.lint import check_headers
-from six import PY3
class TestCheckHeaders(unittest.TestCase):
- @unittest.skipIf(not PY3,'Useless in Python2')
+
+ @unittest.skipIf(not PY3, 'Useless in Python2')
def test_header_unicode_value(self):
- self.assertRaises(AssertionError,check_headers,[('X-Price','100€')])
+ self.assertRaises(AssertionError, check_headers, [('X-Price', '100€')])
- @unittest.skipIf(not PY3,'Useless in Python2')
+ @unittest.skipIf(not PY3, 'Useless in Python2')
def test_header_unicode_name(self):
- self.assertRaises(AssertionError,check_headers,[('X-€','foo')])
-
-
+ self.assertRaises(AssertionError, check_headers, [('X-€', 'foo')])