commit | author | age
|
4a7029
|
1 |
import unittest |
03a0d7
|
2 |
from pyramid.compat import is_unbound_method |
4a7029
|
3 |
|
0c29cf
|
4 |
|
4a7029
|
5 |
class TestUnboundMethods(unittest.TestCase): |
JA |
6 |
def test_old_style_bound(self): |
|
7 |
self.assertFalse(is_unbound_method(OldStyle().run)) |
|
8 |
|
|
9 |
def test_new_style_bound(self): |
|
10 |
self.assertFalse(is_unbound_method(NewStyle().run)) |
|
11 |
|
|
12 |
def test_old_style_unbound(self): |
|
13 |
self.assertTrue(is_unbound_method(OldStyle.run)) |
|
14 |
|
|
15 |
def test_new_style_unbound(self): |
|
16 |
self.assertTrue(is_unbound_method(NewStyle.run)) |
|
17 |
|
|
18 |
def test_normal_func_unbound(self): |
10ddb6
|
19 |
def func(): # pragma: no cover |
0c29cf
|
20 |
return 'OK' |
4a7029
|
21 |
|
JA |
22 |
self.assertFalse(is_unbound_method(func)) |
03a0d7
|
23 |
|
0c29cf
|
24 |
|
03a0d7
|
25 |
class OldStyle: |
10ddb6
|
26 |
def run(self): # pragma: no cover |
0c29cf
|
27 |
return 'OK' |
MM |
28 |
|
03a0d7
|
29 |
|
JA |
30 |
class NewStyle(object): |
10ddb6
|
31 |
def run(self): # pragma: no cover |
0c29cf
|
32 |
return 'OK' |