##// END OF EJS Templates
test_oinspect works with Python 3.
Thomas Kluyver -
Show More
@@ -20,6 +20,7 b' import nose.tools as nt'
20
20
21 # Our own imports
21 # Our own imports
22 from .. import oinspect
22 from .. import oinspect
23 from IPython.utils import py3compat
23
24
24 #-----------------------------------------------------------------------------
25 #-----------------------------------------------------------------------------
25 # Globals and constants
26 # Globals and constants
@@ -96,7 +97,8 b' def test_info():'
96 "Check that Inspector.info fills out various fields as expected."
97 "Check that Inspector.info fills out various fields as expected."
97 i = inspector.info(Call, oname='Call')
98 i = inspector.info(Call, oname='Call')
98 nt.assert_equal(i['type_name'], 'type')
99 nt.assert_equal(i['type_name'], 'type')
99 nt.assert_equal(i['base_class'], "<type 'type'>")
100 expted_class = str(type(type)) # <class 'type'> (Python 3) or <type 'type'>
101 nt.assert_equal(i['base_class'], expted_class)
100 nt.assert_equal(i['string_form'], "<class 'IPython.core.tests.test_oinspect.Call'>")
102 nt.assert_equal(i['string_form'], "<class 'IPython.core.tests.test_oinspect.Call'>")
101 fname = __file__
103 fname = __file__
102 if fname.endswith(".pyc"):
104 if fname.endswith(".pyc"):
@@ -125,9 +127,10 b' def test_info():'
125 nt.assert_equal(i['call_docstring'], c.__call__.__doc__)
127 nt.assert_equal(i['call_docstring'], c.__call__.__doc__)
126
128
127 # Test old-style classes, which for example may not have an __init__ method.
129 # Test old-style classes, which for example may not have an __init__ method.
128 i = inspector.info(OldStyle)
130 if not py3compat.PY3:
129 nt.assert_equal(i['type_name'], 'classobj')
131 i = inspector.info(OldStyle)
130
132 nt.assert_equal(i['type_name'], 'classobj')
131 i = inspector.info(OldStyle())
133
132 nt.assert_equal(i['type_name'], 'instance')
134 i = inspector.info(OldStyle())
133 nt.assert_equal(i['docstring'], OldStyle.__doc__)
135 nt.assert_equal(i['type_name'], 'instance')
136 nt.assert_equal(i['docstring'], OldStyle.__doc__)
General Comments 0
You need to be logged in to leave comments. Login now