summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorDomen Kožar <domen@dev.si>2013-08-07 02:32:53 -0700
committerDomen Kožar <domen@dev.si>2013-08-07 02:32:53 -0700
commit3e91c65d8c0b1d88bf66e713c7e2976e65dc9bf9 (patch)
tree9af387d1a621581a454117a654f656060fe6df28 /tests
parentc248004c1524a2cc2734c6b1e777392530f8d770 (diff)
parent0fb6b70996bfe3487256a2d0ae4d792f743941ed (diff)
downloadwebtest-3e91c65d8c0b1d88bf66e713c7e2976e65dc9bf9.tar.gz
Merge pull request #77 from homm/master
Fix json detection in response
Diffstat (limited to 'tests')
-rw-r--r--tests/test_response.py19
1 files changed, 18 insertions, 1 deletions
diff --git a/tests/test_response.py b/tests/test_response.py
index 43d6cd0..928903b 100644
--- a/tests/test_response.py
+++ b/tests/test_response.py
@@ -102,7 +102,8 @@ def links_app(environ, start_response):
<a href='/foo/'>Foo Bar<span class='baz qux'>Quz</span></a>
</body>
</html>
- """
+ """,
+ '/json/' : '{"foo": "bar"}',
}
utf8_paths = ['/utf8/']
@@ -353,6 +354,22 @@ class TestResponse(unittest.TestCase):
resp.content_type = 'text/xml'
resp.xml
+ def test_json(self):
+ app = webtest.TestApp(links_app)
+
+ resp = app.get('/json/')
+ with self.assertRaises(AttributeError):
+ resp.json
+
+ resp.content_type = 'text/json'
+ self.assertIn('foo', resp.json)
+
+ resp.content_type = 'application/json'
+ self.assertIn('foo', resp.json)
+
+ resp.content_type = 'application/vnd.webtest+json'
+ self.assertIn('foo', resp.json)
+
def test_unicode(self):
app = webtest.TestApp(links_app)