summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/test_compat.py32
-rw-r--r--tests/test_config/test_init.py6
-rw-r--r--tests/test_config/test_views.py14
-rw-r--r--tests/test_util.py23
4 files changed, 32 insertions, 43 deletions
diff --git a/tests/test_compat.py b/tests/test_compat.py
deleted file mode 100644
index 4a14caedf..000000000
--- a/tests/test_compat.py
+++ /dev/null
@@ -1,32 +0,0 @@
-import unittest
-from pyramid.compat import is_unbound_method
-
-
-class TestUnboundMethods(unittest.TestCase):
- def test_old_style_bound(self):
- self.assertFalse(is_unbound_method(OldStyle().run))
-
- def test_new_style_bound(self):
- self.assertFalse(is_unbound_method(NewStyle().run))
-
- def test_old_style_unbound(self):
- self.assertTrue(is_unbound_method(OldStyle.run))
-
- def test_new_style_unbound(self):
- self.assertTrue(is_unbound_method(NewStyle.run))
-
- def test_normal_func_unbound(self):
- def func(): # pragma: no cover
- return 'OK'
-
- self.assertFalse(is_unbound_method(func))
-
-
-class OldStyle:
- def run(self): # pragma: no cover
- return 'OK'
-
-
-class NewStyle(object):
- def run(self): # pragma: no cover
- return 'OK'
diff --git a/tests/test_config/test_init.py b/tests/test_config/test_init.py
index 1cd63f113..ce2b042ec 100644
--- a/tests/test_config/test_init.py
+++ b/tests/test_config/test_init.py
@@ -1,8 +1,6 @@
import os
import unittest
-from pyramid.compat import im_func
-
from . import dummy_tween_factory
from . import dummy_include
from . import dummy_extend
@@ -1205,7 +1203,7 @@ test_config.dummy_include2"""
directives = {'foo': (foo, True)}
config.registry._directives = directives
foo_meth = config.foo
- self.assertTrue(getattr(foo_meth, im_func).__docobj__ is foo)
+ self.assertTrue(getattr(foo_meth, '__func__').__docobj__ is foo)
def test___getattr__matches_no_action_wrap(self):
config = self._makeOne()
@@ -1216,7 +1214,7 @@ test_config.dummy_include2"""
directives = {'foo': (foo, False)}
config.registry._directives = directives
foo_meth = config.foo
- self.assertTrue(getattr(foo_meth, im_func) is foo)
+ self.assertTrue(getattr(foo_meth, '__func__') is foo)
class TestConfigurator_add_directive(unittest.TestCase):
diff --git a/tests/test_config/test_views.py b/tests/test_config/test_views.py
index aa5b67050..d530542b7 100644
--- a/tests/test_config/test_views.py
+++ b/tests/test_config/test_views.py
@@ -3,7 +3,7 @@ import unittest
from zope.interface import implementer
from pyramid import testing
-from pyramid.compat import im_func, text_
+from pyramid.compat import text_
from pyramid.exceptions import ConfigurationError
from pyramid.exceptions import ConfigurationExecutionError
from pyramid.exceptions import ConfigurationConflictError
@@ -3723,16 +3723,16 @@ class Test_preserve_view_attrs(unittest.TestCase):
self.assertTrue(view1.__module__ is view2.__module__)
self.assertTrue(view1.__name__ is view2.__name__)
self.assertTrue(
- getattr(view1.__call_permissive__, im_func)
- is getattr(view2.__call_permissive__, im_func)
+ getattr(view1.__call_permissive__, '__func__')
+ is getattr(view2.__call_permissive__, '__func__')
)
self.assertTrue(
- getattr(view1.__permitted__, im_func)
- is getattr(view2.__permitted__, im_func)
+ getattr(view1.__permitted__, '__func__')
+ is getattr(view2.__permitted__, '__func__')
)
self.assertTrue(
- getattr(view1.__predicated__, im_func)
- is getattr(view2.__predicated__, im_func)
+ getattr(view1.__predicated__, '__func__')
+ is getattr(view2.__predicated__, '__func__')
)
diff --git a/tests/test_util.py b/tests/test_util.py
index 8af5fe557..676290676 100644
--- a/tests/test_util.py
+++ b/tests/test_util.py
@@ -1223,3 +1223,26 @@ class TestSimpleSerializer(unittest.TestCase):
def test_dumps(self):
inst = self._makeOne()
self.assertEqual(inst.dumps('abc'), bytes_('abc'))
+
+
+class TestUnboundMethods(unittest.TestCase):
+ class Dummy(object):
+ def run(self): # pragma: no cover
+ return 'OK'
+
+ def _callFUT(self, val):
+ from pyramid.util import is_unbound_method
+
+ return is_unbound_method(val)
+
+ def test_bound_method(self):
+ self.assertFalse(self._callFUT(self.Dummy().run))
+
+ def test_unbound_method(self):
+ self.assertTrue(self._callFUT(self.Dummy.run))
+
+ def test_normal_func_unbound(self):
+ def func(): # pragma: no cover
+ return 'OK'
+
+ self.assertFalse(self._callFUT(func))