Chris McDonough
2012-01-05 b78b082e3778bb0e0a7c30d4cf711764407e0dcf
coverage
4 files modified
19 ■■■■■ changed files
pyramid/compat.py 6 ●●●● patch | view | raw | blame | history
pyramid/tests/test_traversal.py 4 ●●●● patch | view | raw | blame | history
pyramid/tests/test_urldispatch.py 6 ●●●●● patch | view | raw | blame | history
pyramid/urldispatch.py 3 ●●●● patch | view | raw | blame | history
pyramid/compat.py
@@ -41,7 +41,7 @@
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 @@
    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))
        
pyramid/tests/test_traversal.py
@@ -138,7 +138,7 @@
        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 @@
        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'
pyramid/tests/test_urldispatch.py
@@ -115,6 +115,12 @@
        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')
pyramid/urldispatch.py
@@ -14,7 +14,6 @@
    string_types,
    binary_type,
    is_nonstr_iter,
    url_quote,
    )
from pyramid.exceptions import URLDecodeError
@@ -200,7 +199,7 @@
    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')