##// END OF EJS Templates
[lib][tests][pretty] Remove nose
Samuel Gaist -
Show More
@@ -11,7 +11,6 b' import types'
11 import string
11 import string
12 import unittest
12 import unittest
13
13
14 import nose.tools as nt
15 import pytest
14 import pytest
16
15
17 from IPython.lib import pretty
16 from IPython.lib import pretty
@@ -70,7 +69,6 b' class BreakingRepr(object):'
70 return "Breaking(\n)"
69 return "Breaking(\n)"
71
70
72 class BadRepr(object):
71 class BadRepr(object):
73
74 def __repr__(self):
72 def __repr__(self):
75 return 1/0
73 return 1/0
76
74
@@ -178,7 +176,7 b' def test_pprint_break_repr():'
178
176
179 def test_bad_repr():
177 def test_bad_repr():
180 """Don't catch bad repr errors"""
178 """Don't catch bad repr errors"""
181 with nt.assert_raises(ZeroDivisionError):
179 with pytest.raises(ZeroDivisionError):
182 pretty.pretty(BadRepr())
180 pretty.pretty(BadRepr())
183
181
184 class BadException(Exception):
182 class BadException(Exception):
@@ -190,12 +188,12 b' class ReallyBadRepr(object):'
190 @property
188 @property
191 def __class__(self):
189 def __class__(self):
192 raise ValueError("I am horrible")
190 raise ValueError("I am horrible")
193
191
194 def __repr__(self):
192 def __repr__(self):
195 raise BadException()
193 raise BadException()
196
194
197 def test_really_bad_repr():
195 def test_really_bad_repr():
198 with nt.assert_raises(BadException):
196 with pytest.raises(BadException):
199 pretty.pretty(ReallyBadRepr())
197 pretty.pretty(ReallyBadRepr())
200
198
201
199
@@ -266,11 +264,11 b' def test_metaclass_repr():'
266 def test_unicode_repr():
264 def test_unicode_repr():
267 u = u"üniçodé"
265 u = u"üniçodé"
268 ustr = u
266 ustr = u
269
267
270 class C(object):
268 class C(object):
271 def __repr__(self):
269 def __repr__(self):
272 return ustr
270 return ustr
273
271
274 c = C()
272 c = C()
275 p = pretty.pretty(c)
273 p = pretty.pretty(c)
276 assert p == u
274 assert p == u
@@ -293,7 +291,7 b' def test_basic_class():'
293 output = stream.getvalue()
291 output = stream.getvalue()
294
292
295 assert output == "%s.MyObj" % __name__
293 assert output == "%s.MyObj" % __name__
296 nt.assert_true(type_pprint_wrapper.called)
294 assert type_pprint_wrapper.called is True
297
295
298
296
299 # TODO : pytest.mark.parametrise once nose is gone.
297 # TODO : pytest.mark.parametrise once nose is gone.
@@ -478,7 +476,7 b' def test_function_pretty():'
478 return 42
476 return 42
479 return "Don't panic"
477 return "Don't panic"
480
478
481 nt.assert_in('meaning_of_life(question=None)', pretty.pretty(meaning_of_life))
479 assert "meaning_of_life(question=None)" in pretty.pretty(meaning_of_life)
482
480
483
481
484 class OrderedCounter(Counter, OrderedDict):
482 class OrderedCounter(Counter, OrderedDict):
@@ -497,6 +495,6 b' class MySet(set): # Override repr of a basic type'
497 def test_custom_repr():
495 def test_custom_repr():
498 """A custom repr should override a pretty printer for a parent type"""
496 """A custom repr should override a pretty printer for a parent type"""
499 oc = OrderedCounter("abracadabra")
497 oc = OrderedCounter("abracadabra")
500 nt.assert_in("OrderedCounter(OrderedDict", pretty.pretty(oc))
498 assert "OrderedCounter(OrderedDict" in pretty.pretty(oc)
501
499
502 assert pretty.pretty(MySet()) == "mine"
500 assert pretty.pretty(MySet()) == "mine"
General Comments 0
You need to be logged in to leave comments. Login now