##// END OF EJS Templates
remove nose.assert_equal from IPython/core/tests/test_oinspect.py
Matthias Bussonnier -
Show More
@@ -56,7 +56,7 b' def pyfile(fname):'
56 56
57 57
58 58 def match_pyfiles(f1, f2):
59 nt.assert_equal(pyfile(f1), pyfile(f2))
59 assert pyfile(f1) == pyfile(f2)
60 60
61 61
62 62 def test_find_file():
@@ -76,7 +76,7 b' def test_find_file_decorated1():'
76 76 "My docstring"
77 77
78 78 match_pyfiles(oinspect.find_file(f), os.path.abspath(__file__))
79 nt.assert_equal(f.__doc__, "My docstring")
79 assert f.__doc__ == "My docstring"
80 80
81 81
82 82 def test_find_file_decorated2():
@@ -92,7 +92,7 b' def test_find_file_decorated2():'
92 92 "My docstring 2"
93 93
94 94 match_pyfiles(oinspect.find_file(f), os.path.abspath(__file__))
95 nt.assert_equal(f.__doc__, "My docstring 2")
95 assert f.__doc__ == "My docstring 2"
96 96
97 97
98 98 def test_find_file_magic():
@@ -167,41 +167,46 b' class SerialLiar(object):'
167 167
168 168 def test_info():
169 169 "Check that Inspector.info fills out various fields as expected."
170 i = inspector.info(Call, oname='Call')
171 nt.assert_equal(i['type_name'], 'type')
170 i = inspector.info(Call, oname="Call")
171 assert i["type_name"] == "type"
172 172 expted_class = str(type(type)) # <class 'type'> (Python 3) or <type 'type'>
173 nt.assert_equal(i['base_class'], expted_class)
174 nt.assert_regex(i['string_form'], "<class 'IPython.core.tests.test_oinspect.Call'( at 0x[0-9a-f]{1,9})?>")
173 assert i["base_class"] == expted_class
174 nt.assert_regex(
175 i["string_form"],
176 "<class 'IPython.core.tests.test_oinspect.Call'( at 0x[0-9a-f]{1,9})?>",
177 )
175 178 fname = __file__
176 179 if fname.endswith(".pyc"):
177 180 fname = fname[:-1]
178 181 # case-insensitive comparison needed on some filesystems
179 182 # e.g. Windows:
180 nt.assert_equal(i['file'].lower(), compress_user(fname).lower())
181 nt.assert_equal(i['definition'], None)
182 nt.assert_equal(i['docstring'], Call.__doc__)
183 nt.assert_equal(i['source'], None)
184 nt.assert_true(i['isclass'])
185 nt.assert_equal(i['init_definition'], "Call(x, y=1)")
186 nt.assert_equal(i['init_docstring'], Call.__init__.__doc__)
183 assert i["file"].lower() == compress_user(fname).lower()
184 assert i["definition"] == None
185 assert i["docstring"] == Call.__doc__
186 assert i["source"] == None
187 nt.assert_true(i["isclass"])
188 assert i["init_definition"] == "Call(x, y=1)"
189 assert i["init_docstring"] == Call.__init__.__doc__
187 190
188 191 i = inspector.info(Call, detail_level=1)
189 nt.assert_not_equal(i['source'], None)
190 nt.assert_equal(i['docstring'], None)
192 nt.assert_not_equal(i["source"], None)
193 assert i["docstring"] == None
191 194
192 195 c = Call(1)
193 196 c.__doc__ = "Modified instance docstring"
194 197 i = inspector.info(c)
195 nt.assert_equal(i['type_name'], 'Call')
196 nt.assert_equal(i['docstring'], "Modified instance docstring")
197 nt.assert_equal(i['class_docstring'], Call.__doc__)
198 nt.assert_equal(i['init_docstring'], Call.__init__.__doc__)
199 nt.assert_equal(i['call_docstring'], Call.__call__.__doc__)
198 assert i["type_name"] == "Call"
199 assert i["docstring"] == "Modified instance docstring"
200 assert i["class_docstring"] == Call.__doc__
201 assert i["init_docstring"] == Call.__init__.__doc__
202 assert i["call_docstring"] == Call.__call__.__doc__
203
200 204
201 205 def test_class_signature():
202 info = inspector.info(HasSignature, 'HasSignature')
203 nt.assert_equal(info['init_definition'], "HasSignature(test)")
204 nt.assert_equal(info['init_docstring'], HasSignature.__init__.__doc__)
206 info = inspector.info(HasSignature, "HasSignature")
207 assert info["init_definition"] == "HasSignature(test)"
208 assert info["init_docstring"] == HasSignature.__init__.__doc__
209
205 210
206 211 def test_info_awkward():
207 212 # Just test that this doesn't throw an error.
@@ -231,8 +236,9 b' def f_kwarg(pos, *, kwonly):'
231 236 pass
232 237
233 238 def test_definition_kwonlyargs():
234 i = inspector.info(f_kwarg, oname='f_kwarg') # analysis:ignore
235 nt.assert_equal(i['definition'], "f_kwarg(pos, *, kwonly)")
239 i = inspector.info(f_kwarg, oname="f_kwarg") # analysis:ignore
240 assert i["definition"] == "f_kwarg(pos, *, kwonly)"
241
236 242
237 243 def test_getdoc():
238 244 class A(object):
@@ -253,9 +259,9 b' def test_getdoc():'
253 259 b = B()
254 260 c = C()
255 261
256 nt.assert_equal(oinspect.getdoc(a), "standard docstring")
257 nt.assert_equal(oinspect.getdoc(b), "custom docstring")
258 nt.assert_equal(oinspect.getdoc(c), "standard docstring")
262 assert oinspect.getdoc(a) == "standard docstring"
263 assert oinspect.getdoc(b) == "custom docstring"
264 assert oinspect.getdoc(c) == "standard docstring"
259 265
260 266
261 267 def test_empty_property_has_no_source():
@@ -299,15 +305,17 b' def test_property_docstring_is_in_info_for_detail_level_0():'
299 305 """This is `foobar` property."""
300 306 pass
301 307
302 ip.user_ns['a_obj'] = A()
303 nt.assert_equal(
304 'This is `foobar` property.',
305 ip.object_inspect('a_obj.foobar', detail_level=0)['docstring'])
308 ip.user_ns["a_obj"] = A()
309 assert (
310 "This is `foobar` property."
311 == ip.object_inspect("a_obj.foobar", detail_level=0)["docstring"]
312 )
306 313
307 ip.user_ns['a_cls'] = A
308 nt.assert_equal(
309 'This is `foobar` property.',
310 ip.object_inspect('a_cls.foobar', detail_level=0)['docstring'])
314 ip.user_ns["a_cls"] = A
315 assert (
316 "This is `foobar` property."
317 == ip.object_inspect("a_cls.foobar", detail_level=0)["docstring"]
318 )
311 319
312 320
313 321 def test_pdef():
@@ -404,7 +412,7 b' def test_render_signature_short():'
404 412 signature(short_fun),
405 413 short_fun.__name__,
406 414 )
407 nt.assert_equal(sig, 'short_fun(a=1)')
415 assert sig == "short_fun(a=1)"
408 416
409 417
410 418 def test_render_signature_long():
General Comments 0
You need to be logged in to leave comments. Login now