summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/pkgs/forbiddenapp/__init__.py2
-rw-r--r--tests/test_authentication.py2
-rw-r--r--tests/test_config/test_predicates.py2
-rw-r--r--tests/test_config/test_routes.py2
-rw-r--r--tests/test_config/test_testing.py2
-rw-r--r--tests/test_config/test_views.py2
-rw-r--r--tests/test_encode.py4
-rw-r--r--tests/test_httpexceptions.py2
-rw-r--r--tests/test_integration.py6
-rw-r--r--tests/test_predicates.py2
-rw-r--r--tests/test_renderers.py4
-rw-r--r--tests/test_request.py4
-rw-r--r--tests/test_response.py2
-rw-r--r--tests/test_traversal.py7
-rw-r--r--tests/test_url.py3
-rw-r--r--tests/test_urldispatch.py2
-rw-r--r--tests/test_util.py23
17 files changed, 38 insertions, 33 deletions
diff --git a/tests/pkgs/forbiddenapp/__init__.py b/tests/pkgs/forbiddenapp/__init__.py
index 9ebf62a9d..31ea4dd52 100644
--- a/tests/pkgs/forbiddenapp/__init__.py
+++ b/tests/pkgs/forbiddenapp/__init__.py
@@ -1,6 +1,6 @@
from webob import Response
from pyramid.httpexceptions import HTTPForbidden
-from pyramid.compat import bytes_
+from pyramid.util import bytes_
def x_view(request): # pragma: no cover
diff --git a/tests/test_authentication.py b/tests/test_authentication.py
index a18ccaeb4..8671eba05 100644
--- a/tests/test_authentication.py
+++ b/tests/test_authentication.py
@@ -2,7 +2,7 @@ from http.cookies import SimpleCookie
import unittest
import warnings
from pyramid import testing
-from pyramid.compat import text_, bytes_
+from pyramid.util import text_, bytes_
class TestCallbackAuthenticationPolicyDebugging(unittest.TestCase):
diff --git a/tests/test_config/test_predicates.py b/tests/test_config/test_predicates.py
index 079652b39..c27b41639 100644
--- a/tests/test_config/test_predicates.py
+++ b/tests/test_config/test_predicates.py
@@ -1,6 +1,6 @@
import unittest
-from pyramid.compat import text_
+from pyramid.util import text_
class TestPredicateList(unittest.TestCase):
diff --git a/tests/test_config/test_routes.py b/tests/test_config/test_routes.py
index e6540c343..4ff67cf66 100644
--- a/tests/test_config/test_routes.py
+++ b/tests/test_config/test_routes.py
@@ -2,7 +2,7 @@ import unittest
from . import dummyfactory
from . import DummyContext
-from pyramid.compat import text_
+from pyramid.util import text_
class RoutesConfiguratorMixinTests(unittest.TestCase):
diff --git a/tests/test_config/test_testing.py b/tests/test_config/test_testing.py
index 870bbe9fa..0fb73d268 100644
--- a/tests/test_config/test_testing.py
+++ b/tests/test_config/test_testing.py
@@ -1,8 +1,8 @@
import unittest
from zope.interface import implementer
-from pyramid.compat import text_
from pyramid.security import AuthenticationAPIMixin, AuthorizationAPIMixin
+from pyramid.util import text_
from . import IDummy
diff --git a/tests/test_config/test_views.py b/tests/test_config/test_views.py
index e25ee881e..685b81a0f 100644
--- a/tests/test_config/test_views.py
+++ b/tests/test_config/test_views.py
@@ -3,11 +3,11 @@ import unittest
from zope.interface import implementer
from pyramid import testing
-from pyramid.compat import text_
from pyramid.exceptions import ConfigurationError
from pyramid.exceptions import ConfigurationExecutionError
from pyramid.exceptions import ConfigurationConflictError
from pyramid.interfaces import IResponse, IRequest, IMultiView
+from pyramid.util import text_
from . import IDummy
from . import dummy_view
diff --git a/tests/test_encode.py b/tests/test_encode.py
index f70050cac..4df08d509 100644
--- a/tests/test_encode.py
+++ b/tests/test_encode.py
@@ -1,5 +1,5 @@
import unittest
-from pyramid.compat import text_, native_
+from pyramid.util import text_
class UrlEncodeTests(unittest.TestCase):
@@ -74,7 +74,7 @@ class URLQuoteTests(unittest.TestCase):
self.assertEqual(result, 'La%2FPe%C3%B1a')
def test_it_native(self):
- la = native_(b'La/Pe\xc3\xb1a', 'utf-8')
+ la = text_(b'La/Pe\xc3\xb1a', 'utf-8')
result = self._callFUT(la)
self.assertEqual(result, 'La%2FPe%C3%B1a')
diff --git a/tests/test_httpexceptions.py b/tests/test_httpexceptions.py
index 48c4a22f3..5decfc39c 100644
--- a/tests/test_httpexceptions.py
+++ b/tests/test_httpexceptions.py
@@ -1,6 +1,6 @@
import unittest
-from pyramid.compat import bytes_, text_
+from pyramid.util import bytes_, text_
class Test_exception_response(unittest.TestCase):
diff --git a/tests/test_integration.py b/tests/test_integration.py
index 0652d8ee8..d1f65274b 100644
--- a/tests/test_integration.py
+++ b/tests/test_integration.py
@@ -8,11 +8,11 @@ from urllib.parse import quote
from webtest import TestApp
from zope.interface import Interface
-from pyramid.wsgi import wsgiapp
-from pyramid.view import view_config
from pyramid.static import static_view
from pyramid.testing import skip_on
-from pyramid.compat import text_
+from pyramid.util import text_
+from pyramid.view import view_config
+from pyramid.wsgi import wsgiapp
from .pkgs.exceptionviewapp.models import AnException, NotAnException
diff --git a/tests/test_predicates.py b/tests/test_predicates.py
index c072b4229..a99651a8f 100644
--- a/tests/test_predicates.py
+++ b/tests/test_predicates.py
@@ -2,7 +2,7 @@ import unittest
from pyramid import testing
-from pyramid.compat import text_
+from pyramid.util import text_
class TestXHRPredicate(unittest.TestCase):
diff --git a/tests/test_renderers.py b/tests/test_renderers.py
index 0e9f99d15..db8b3b4f2 100644
--- a/tests/test_renderers.py
+++ b/tests/test_renderers.py
@@ -1,8 +1,8 @@
import unittest
-from pyramid.testing import cleanUp
from pyramid import testing
-from pyramid.compat import text_
+from pyramid.testing import cleanUp
+from pyramid.util import text_
class TestJSON(unittest.TestCase):
diff --git a/tests/test_request.py b/tests/test_request.py
index 60cc2b31a..484d86e01 100644
--- a/tests/test_request.py
+++ b/tests/test_request.py
@@ -1,8 +1,8 @@
import unittest
from pyramid import testing
-from pyramid.compat import text_, bytes_, native_
from pyramid.security import AuthenticationAPIMixin, AuthorizationAPIMixin
+from pyramid.util import text_, bytes_
class TestRequest(unittest.TestCase):
@@ -478,7 +478,7 @@ class Test_call_app_with_subpath_as_path_info(unittest.TestCase):
self.assertEqual(request.environ['PATH_INFO'], '/hello/')
def test_subpath_path_info_and_script_name_have_utf8(self):
- encoded = native_(text_(b'La Pe\xc3\xb1a'))
+ encoded = text_(b'La Pe\xc3\xb1a')
decoded = text_(bytes_(encoded), 'utf-8')
request = DummyRequest(
{'PATH_INFO': '/' + encoded, 'SCRIPT_NAME': '/' + encoded}
diff --git a/tests/test_response.py b/tests/test_response.py
index 5231e47f0..18d4335ad 100644
--- a/tests/test_response.py
+++ b/tests/test_response.py
@@ -73,9 +73,9 @@ class TestFileResponse(unittest.TestCase):
# function returns Unicode for the content_type, unlike any previous
# version of Python. See https://github.com/Pylons/pyramid/issues/1360
# for more information.
- from pyramid.compat import text_
import mimetypes as old_mimetypes
from pyramid import response
+ from pyramid.util import text_
class FakeMimetypesModule(object):
def guess_type(self, *arg, **kw):
diff --git a/tests/test_traversal.py b/tests/test_traversal.py
index 252e99f6f..de712a6e8 100644
--- a/tests/test_traversal.py
+++ b/tests/test_traversal.py
@@ -4,7 +4,7 @@ from urllib.parse import quote
from pyramid.testing import cleanUp
-from pyramid.compat import text_, native_
+from pyramid.util import text_
class TraversalPathTests(unittest.TestCase):
@@ -87,15 +87,14 @@ class TraversalPathInfoTests(unittest.TestCase):
def test_highorder(self):
la = b'La Pe\xc3\xb1a'
- latin1 = native_(la)
+ latin1 = text_(la)
result = self._callFUT(latin1)
self.assertEqual(result, (text_(la, 'utf-8'),))
def test_highorder_undecodeable(self):
from pyramid.exceptions import URLDecodeError
- la = text_(b'La Pe\xc3\xb1a', 'utf-8')
- notlatin1 = native_(la)
+ notlatin1 = text_(b'La Pe\xc3\xb1a', 'utf-8')
self.assertRaises(URLDecodeError, self._callFUT, notlatin1)
diff --git a/tests/test_url.py b/tests/test_url.py
index a852f3301..4c761ce50 100644
--- a/tests/test_url.py
+++ b/tests/test_url.py
@@ -3,7 +3,8 @@ import unittest
from pyramid import testing
-from pyramid.compat import text_, WIN
+from pyramid.compat import WIN
+from pyramid.util import text_
class TestURLMethodsMixin(unittest.TestCase):
diff --git a/tests/test_urldispatch.py b/tests/test_urldispatch.py
index a74731730..5d77042ae 100644
--- a/tests/test_urldispatch.py
+++ b/tests/test_urldispatch.py
@@ -1,6 +1,6 @@
import unittest
from pyramid import testing
-from pyramid.compat import text_
+from pyramid.util import text_
class TestRoute(unittest.TestCase):
diff --git a/tests/test_util.py b/tests/test_util.py
index d6d1d1502..0f313955b 100644
--- a/tests/test_util.py
+++ b/tests/test_util.py
@@ -1,6 +1,6 @@
import sys
import unittest
-from pyramid.compat import text_, bytes_
+from pyramid.util import text_, bytes_
class Test_InstancePropertyHelper(unittest.TestCase):
@@ -833,21 +833,26 @@ class TestSentinel(unittest.TestCase):
class TestCallableName(unittest.TestCase):
- def test_valid_ascii(self):
+ def _callFUT(self, val):
from pyramid.util import get_callable_name
+ return get_callable_name(val)
+
+ def test_valid_ascii_bytes(self):
name = b'hello world'
- self.assertEqual(get_callable_name(name), 'hello world')
+ self.assertEqual(self._callFUT(name), 'hello world')
- def test_invalid_ascii(self):
- from pyramid.util import get_callable_name
+ def test_valid_ascii_string(self):
from pyramid.exceptions import ConfigurationError
- def get_bad_name():
- name = b'La Pe\xc3\xb1a'
- get_callable_name(name)
+ name = b'La Pe\xc3\xb1a'.decode('utf-8')
+ self.assertRaises(ConfigurationError, self._callFUT, name)
- self.assertRaises(ConfigurationError, get_bad_name)
+ def test_invalid_ascii(self):
+ from pyramid.exceptions import ConfigurationError
+
+ name = b'La Pe\xc3\xb1a'
+ self.assertRaises(ConfigurationError, self._callFUT, name)
class Test_hide_attrs(unittest.TestCase):