diff options
| author | Chris McDonough <chrism@plope.com> | 2012-01-05 08:34:23 -0500 |
|---|---|---|
| committer | Chris McDonough <chrism@plope.com> | 2012-01-05 08:34:23 -0500 |
| commit | b78b082e3778bb0e0a7c30d4cf711764407e0dcf (patch) | |
| tree | 0d36ac63c6b8d774e020b037c476e0ccde5c8797 | |
| parent | c52c927e930f44c25912c8e5d444489e95ea9d31 (diff) | |
| download | pyramid-b78b082e3778bb0e0a7c30d4cf711764407e0dcf.tar.gz pyramid-b78b082e3778bb0e0a7c30d4cf711764407e0dcf.tar.bz2 pyramid-b78b082e3778bb0e0a7c30d4cf711764407e0dcf.zip | |
coverage
| -rw-r--r-- | pyramid/compat.py | 6 | ||||
| -rw-r--r-- | pyramid/tests/test_traversal.py | 4 | ||||
| -rw-r--r-- | pyramid/tests/test_urldispatch.py | 6 | ||||
| -rw-r--r-- | pyramid/urldispatch.py | 3 |
4 files changed, 12 insertions, 7 deletions
diff --git a/pyramid/compat.py b/pyramid/compat.py index 7376278ac..948a1c3be 100644 --- a/pyramid/compat.py +++ b/pyramid/compat.py @@ -41,7 +41,7 @@ def text_(s, encoding='latin-1', errors='strict'): def bytes_(s, encoding='latin-1', errors='strict'): """ If ``s`` is an instance of ``text_type``, return ``s.encode(encoding, errors)``, otherwise return ``s``""" - if isinstance(s, text_type): + if isinstance(s, text_type): # pragma: no cover return s.encode(encoding, errors) return s @@ -105,10 +105,10 @@ else: from urllib import unquote as url_unquote from urllib import urlencode as url_encode from urllib2 import urlopen as url_open - def url_unquote_text(v, encoding='utf-8', errors='replace'): + def url_unquote_text(v, encoding='utf-8', errors='replace'): # pragma: no cover v = url_unquote(v) return v.decode(encoding, errors) - def url_unquote_native(v, encoding='utf-8', errors='replace'): + def url_unquote_native(v, encoding='utf-8', errors='replace'): # pragma: no cover return native_(url_unquote_text(v, encoding, errors)) diff --git a/pyramid/tests/test_traversal.py b/pyramid/tests/test_traversal.py index c9685b124..1f9971ca5 100644 --- a/pyramid/tests/test_traversal.py +++ b/pyramid/tests/test_traversal.py @@ -138,7 +138,7 @@ class ResourceTreeTraverserTests(unittest.TestCase): foo = DummyContext(None, text_(b'Qu\xc3\xa9bec', 'utf-8')) root = DummyContext(foo, 'root') policy = self._makeOne(root) - if PY3: + if PY3: # pragma: no cover path_info = b'/Qu\xc3\xa9bec'.decode('latin-1') else: path_info = b'/Qu\xc3\xa9bec' @@ -325,7 +325,7 @@ class ResourceTreeTraverserTests(unittest.TestCase): foo = DummyContext(bar, text_(b'Qu\xc3\xa9bec', 'utf-8')) root = DummyContext(foo, 'root') policy = self._makeOne(root) - if PY3: + if PY3: # pragma: no cover vhm_root = b'/Qu\xc3\xa9bec'.decode('latin-1') else: vhm_root = b'/Qu\xc3\xa9bec' diff --git a/pyramid/tests/test_urldispatch.py b/pyramid/tests/test_urldispatch.py index 286cc1573..370f072ff 100644 --- a/pyramid/tests/test_urldispatch.py +++ b/pyramid/tests/test_urldispatch.py @@ -115,6 +115,12 @@ class RoutesMapperTests(unittest.TestCase): self.assertEqual(mapper.routelist[0].pattern, 'archives/:action/:article2') + def test___call__pathinfo_cant_be_decoded(self): + from pyramid.exceptions import URLDecodeError + mapper = self._makeOne() + request = self._getRequest(PATH_INFO=b'\xff\xfe\xe6\x00') + self.assertRaises(URLDecodeError, mapper, request) + def test___call__route_matches(self): mapper = self._makeOne() mapper.connect('foo', 'archives/:action/:article') diff --git a/pyramid/urldispatch.py b/pyramid/urldispatch.py index fcd6c55c9..bd1da8f71 100644 --- a/pyramid/urldispatch.py +++ b/pyramid/urldispatch.py @@ -14,7 +14,6 @@ from pyramid.compat import ( string_types, binary_type, is_nonstr_iter, - url_quote, ) from pyramid.exceptions import URLDecodeError @@ -200,7 +199,7 @@ def _compile_route(route): def generator(dict): newdict = {} for k, v in dict.items(): - if PY3: + if PY3: # pragma: no cover if v.__class__ is binary_type: # url_quote below needs a native string, not bytes on Py3 v = v.decode('utf-8') |
