Skip to content

Commit a4b174c

Browse files
fix python 3
1 parent 427dd1f commit a4b174c

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

bpython/test/test_inspection.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
import os
44

5+
6+
from bpython._py3compat import py3
57
from bpython import inspection
68
from bpython.test import unittest
79
from bpython.test.fodder import encoding_ascii
@@ -59,14 +61,25 @@ def test_is_callable(self):
5961
self.assertFalse(inspection.is_callable(None))
6062
self.assertTrue(inspection.is_callable(CallableMethod().method))
6163

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):
6366
self.assertTrue(inspection.is_new_style(spam))
6467
self.assertTrue(inspection.is_new_style(Noncallable))
6568
self.assertFalse(inspection.is_new_style(OldNoncallable))
6669
self.assertTrue(inspection.is_new_style(Noncallable()))
6770
self.assertFalse(inspection.is_new_style(OldNoncallable()))
6871
self.assertTrue(inspection.is_new_style(None))
6972

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+
7083
def test_parsekeywordpairs(self):
7184
# See issue #109
7285
def fails(spam=['-a', '-b']):
@@ -169,6 +182,7 @@ def test_avoid_running_properties(self):
169182
self.assertEquals(inspection.safe_get_attribute_new_style(p, 'prop'),
170183
Property.prop)
171184

185+
@unittest.skipIf(py3, 'Old-style classes not in Python 3')
172186
def test_raises_on_old_style_class(self):
173187
class Old: pass
174188
with self.assertRaises(ValueError):

0 commit comments

Comments
 (0)