|
2 | 2 |
|
3 | 3 | import os |
4 | 4 |
|
| 5 | + |
| 6 | +from bpython._py3compat import py3 |
5 | 7 | from bpython import inspection |
6 | 8 | from bpython.test import unittest |
7 | 9 | from bpython.test.fodder import encoding_ascii |
@@ -59,14 +61,25 @@ def test_is_callable(self): |
59 | 61 | self.assertFalse(inspection.is_callable(None)) |
60 | 62 | self.assertTrue(inspection.is_callable(CallableMethod().method)) |
61 | 63 |
|
62 | | - def test_is_new_style(self): |
| 64 | + @unittest.skipIf(py3, 'old-style classes only exist in Python 2') |
| 65 | + def test_is_new_style_py2(self): |
63 | 66 | self.assertTrue(inspection.is_new_style(spam)) |
64 | 67 | self.assertTrue(inspection.is_new_style(Noncallable)) |
65 | 68 | self.assertFalse(inspection.is_new_style(OldNoncallable)) |
66 | 69 | self.assertTrue(inspection.is_new_style(Noncallable())) |
67 | 70 | self.assertFalse(inspection.is_new_style(OldNoncallable())) |
68 | 71 | self.assertTrue(inspection.is_new_style(None)) |
69 | 72 |
|
| 73 | + @unittest.skipUnless(py3, 'only in Python 3 are all classes new-style') |
| 74 | + def test_is_new_style_py3(self): |
| 75 | + self.assertTrue(inspection.is_new_style(spam)) |
| 76 | + self.assertTrue(inspection.is_new_style(Noncallable)) |
| 77 | + self.assertTrue(inspection.is_new_style(OldNoncallable)) |
| 78 | + self.assertTrue(inspection.is_new_style(Noncallable())) |
| 79 | + self.assertTrue(inspection.is_new_style(OldNoncallable())) |
| 80 | + self.assertTrue(inspection.is_new_style(None)) |
| 81 | + |
| 82 | + |
70 | 83 | def test_parsekeywordpairs(self): |
71 | 84 | # See issue #109 |
72 | 85 | def fails(spam=['-a', '-b']): |
@@ -169,6 +182,7 @@ def test_avoid_running_properties(self): |
169 | 182 | self.assertEquals(inspection.safe_get_attribute_new_style(p, 'prop'), |
170 | 183 | Property.prop) |
171 | 184 |
|
| 185 | + @unittest.skipIf(py3, 'Old-style classes not in Python 3') |
172 | 186 | def test_raises_on_old_style_class(self): |
173 | 187 | class Old: pass |
174 | 188 | with self.assertRaises(ValueError): |
|
0 commit comments