summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGael Pasgrimaud <gael@gawel.org>2014-04-16 23:35:50 +0200
committerGael Pasgrimaud <gael@gawel.org>2014-04-16 23:35:50 +0200
commit2965c23e4d995c6ca85296a49167fda7457713a9 (patch)
tree29f88e1a149f9f36c0219350a04c8c63decaad35
parentd2471e042c5b33100bb742247b7ef44c1ff9ea02 (diff)
downloadwebtest-2965c23e4d995c6ca85296a49167fda7457713a9.tar.gz
improve test coverage. we're back at 100%
-rw-r--r--tests/test_app.py11
-rw-r--r--tests/test_debugapp.py2
-rw-r--r--webtest/app.py5
-rw-r--r--webtest/forms.py2
-rw-r--r--webtest/http.py2
-rw-r--r--webtest/utils.py3
6 files changed, 20 insertions, 5 deletions
diff --git a/tests/test_app.py b/tests/test_app.py
index 8352b93..ce0cfeb 100644
--- a/tests/test_app.py
+++ b/tests/test_app.py
@@ -74,6 +74,9 @@ class TestApp(unittest.TestCase):
resp = self.app.patch('/')
self.assertIn('PATCH', resp)
+ resp = self.app.patch('/', xhr=True)
+ self.assertIn('PATCH', resp)
+
def test_custom_headers(self):
resp = self.app.post('/', headers={'Accept': 'text/plain'})
resp.charset = 'ascii'
@@ -107,6 +110,14 @@ class TestStatus(unittest.TestCase):
self.assertRaises(webtest.AppError, self.check_status, '400 Ok')
+class TestParserFeature(unittest.TestCase):
+
+ def test_parser_features(self):
+ app = webtest.TestApp(debug_app, parser_features='custom')
+ self.assertEqual(app.RequestClass.ResponseClass.parser_features,
+ 'custom')
+
+
class TestAppError(unittest.TestCase):
def test_app_error(self):
diff --git a/tests/test_debugapp.py b/tests/test_debugapp.py
index 2375f8c..87c61a0 100644
--- a/tests/test_debugapp.py
+++ b/tests/test_debugapp.py
@@ -43,6 +43,8 @@ class TestTesting(unittest.TestCase):
self.assertEqual(res.headers['content-type'], 'text/plain')
self.assertTrue(res.content_length > 0)
self.assertEqual(res.body, to_bytes(''))
+ res = self.app.head('/', xhr=True)
+ self.assertEqual(res.status_int, 200)
def test_post_unicode(self):
res = self.app.post(
diff --git a/webtest/app.py b/webtest/app.py
index 40a7723..df22abc 100644
--- a/webtest/app.py
+++ b/webtest/app.py
@@ -146,8 +146,9 @@ class TestApp(object):
self.extra_environ = extra_environ
self.use_unicode = use_unicode
self.cookiejar = cookiejar or http_cookiejar.CookieJar()
- if parser_features:
- self.RequestClass.ResponseClass.parser_features = parser_features
+ if parser_features is None:
+ parser_features = 'html.parser'
+ self.RequestClass.ResponseClass.parser_features = parser_features
def get_authorization(self):
"""Allow to set the HTTP_AUTHORIZATION environ key. Value should looks
diff --git a/webtest/forms.py b/webtest/forms.py
index c9c7ee0..8a43001 100644
--- a/webtest/forms.py
+++ b/webtest/forms.py
@@ -426,7 +426,7 @@ class Form(object):
name = attrs.pop('name')
if tag == 'textarea':
- if node.text.startswith('\r\n'):
+ if node.text.startswith('\r\n'): # pragma: no cover
text = node.text[2:]
elif node.text.startswith('\n'):
text = node.text[1:]
diff --git a/webtest/http.py b/webtest/http.py
index f2e5f85..90959ec 100644
--- a/webtest/http.py
+++ b/webtest/http.py
@@ -86,7 +86,7 @@ class StopableWSGIServer(TcpWSGIServer):
"""Run the server"""
try:
self.asyncore.loop(.5, map=self._map)
- except select.error:
+ except select.error: # pragma: no cover
if not self.was_shutdown:
raise
diff --git a/webtest/utils.py b/webtest/utils.py
index ac78bcd..84b296e 100644
--- a/webtest/utils.py
+++ b/webtest/utils.py
@@ -133,7 +133,8 @@ class _RequestCookieAdapter(object):
# This is undocumented method that Python 3 cookielib uses
return self.get_type()
- def header_items(self):
+ def header_items(self): # pragma: no cover
+ # This is unused on most python versions
return self._request.headers.items()