##// END OF EJS Templates
Remove some nose
Matthias Bussonnier -
Show More
@@ -48,16 +48,16 b' def foo_printer(obj, pp, cycle):'
48 48 def test_pretty():
49 49 f = PlainTextFormatter()
50 50 f.for_type(A, foo_printer)
51 nt.assert_equal(f(A()), 'foo')
52 nt.assert_equal(f(B()), 'B()')
53 nt.assert_equal(f(GoodPretty()), 'foo')
51 assert f(A()) == "foo"
52 assert f(B()) == "B()"
53 assert f(GoodPretty()) == "foo"
54 54 # Just don't raise an exception for the following:
55 55 f(BadPretty())
56 56
57 57 f.pprint = False
58 nt.assert_equal(f(A()), 'A()')
59 nt.assert_equal(f(B()), 'B()')
60 nt.assert_equal(f(GoodPretty()), 'GoodPretty()')
58 assert f(A()) == "A()"
59 assert f(B()) == "B()"
60 assert f(GoodPretty()) == "GoodPretty()"
61 61
62 62
63 63 def test_deferred():
@@ -66,29 +66,30 b' def test_deferred():'
66 66 def test_precision():
67 67 """test various values for float_precision."""
68 68 f = PlainTextFormatter()
69 nt.assert_equal(f(pi), repr(pi))
69 assert f(pi) == repr(pi)
70 70 f.float_precision = 0
71 71 if numpy:
72 72 po = numpy.get_printoptions()
73 nt.assert_equal(po['precision'], 0)
74 nt.assert_equal(f(pi), '3')
73 assert po["precision"] == 0
74 assert f(pi) == "3"
75 75 f.float_precision = 2
76 76 if numpy:
77 77 po = numpy.get_printoptions()
78 nt.assert_equal(po['precision'], 2)
79 nt.assert_equal(f(pi), '3.14')
80 f.float_precision = '%g'
78 assert po["precision"] == 2
79 assert f(pi) == "3.14"
80 f.float_precision = "%g"
81 81 if numpy:
82 82 po = numpy.get_printoptions()
83 nt.assert_equal(po['precision'], 2)
84 nt.assert_equal(f(pi), '3.14159')
85 f.float_precision = '%e'
86 nt.assert_equal(f(pi), '3.141593e+00')
87 f.float_precision = ''
83 assert po["precision"] == 2
84 assert f(pi) == "3.14159"
85 f.float_precision = "%e"
86 assert f(pi) == "3.141593e+00"
87 f.float_precision = ""
88 88 if numpy:
89 89 po = numpy.get_printoptions()
90 nt.assert_equal(po['precision'], 8)
91 nt.assert_equal(f(pi), repr(pi))
90 assert po["precision"] == 8
91 assert f(pi) == repr(pi)
92
92 93
93 94 def test_bad_precision():
94 95 """test various invalid values for float_precision."""
@@ -260,8 +261,9 b' def test_nowarn_notimplemented():'
260 261 with capture_output() as captured:
261 262 result = f(h)
262 263 nt.assert_is(result, None)
263 nt.assert_equal("", captured.stderr)
264 nt.assert_equal("", captured.stdout)
264 assert "" == captured.stderr
265 assert "" == captured.stdout
266
265 267
266 268 def test_warn_error_for_type():
267 269 f = HTMLFormatter()
@@ -307,7 +309,8 b' class MakePDF(object):'
307 309 def test_pdf_formatter():
308 310 pdf = MakePDF()
309 311 f = PDFFormatter()
310 nt.assert_equal(f(pdf), 'PDF')
312 assert f(pdf) == "PDF"
313
311 314
312 315 def test_print_method_bound():
313 316 f = HTMLFormatter()
@@ -321,8 +324,9 b' def test_print_method_bound():'
321 324
322 325 with capture_output() as captured:
323 326 result = f(MyHTML())
324 nt.assert_equal(result, "hello")
325 nt.assert_equal(captured.stderr, "")
327 assert result == "hello"
328 assert captured.stderr == ""
329
326 330
327 331 def test_print_method_weird():
328 332
@@ -331,9 +335,9 b' def test_print_method_weird():'
331 335 return key
332 336
333 337 f = HTMLFormatter()
334
338
335 339 text_hat = TextMagicHat()
336 nt.assert_equal(text_hat._repr_html_, '_repr_html_')
340 assert text_hat._repr_html_ == "_repr_html_"
337 341 with capture_output() as captured:
338 342 result = f(text_hat)
339 343
@@ -347,8 +351,8 b' def test_print_method_weird():'
347 351 call_hat = CallableMagicHat()
348 352 with capture_output() as captured:
349 353 result = f(call_hat)
350
351 nt.assert_equal(result, None)
354
355 assert result == None
352 356
353 357 class BadReprArgs(object):
354 358 def _repr_html_(self, extra, args):
@@ -369,24 +373,25 b' def test_format_config():'
369 373 with capture_output() as captured:
370 374 result = f(cfg)
371 375 nt.assert_is(result, None)
372 nt.assert_equal(captured.stderr, "")
376 assert captured.stderr == ""
373 377
374 378 with capture_output() as captured:
375 379 result = f(Config)
376 380 nt.assert_is(result, None)
377 nt.assert_equal(captured.stderr, "")
381 assert captured.stderr == ""
382
378 383
379 384 def test_pretty_max_seq_length():
380 385 f = PlainTextFormatter(max_seq_length=1)
381 386 lis = list(range(3))
382 387 text = f(lis)
383 nt.assert_equal(text, '[0, ...]')
388 assert text == "[0, ...]"
384 389 f.max_seq_length = 0
385 390 text = f(lis)
386 nt.assert_equal(text, '[0, 1, 2]')
391 assert text == "[0, 1, 2]"
387 392 text = f(list(range(1024)))
388 393 lines = text.splitlines()
389 nt.assert_equal(len(lines), 1024)
394 assert len(lines) == 1024
390 395
391 396
392 397 def test_ipython_display_formatter():
@@ -409,16 +414,16 b' def test_ipython_display_formatter():'
409 414
410 415 yes = SelfDisplaying()
411 416 no = NotSelfDisplaying()
412
417
413 418 d, md = f.format(no)
414 nt.assert_equal(d, {'text/plain': repr(no)})
415 nt.assert_equal(md, {})
416 nt.assert_equal(catcher, [])
417
419 assert d == {"text/plain": repr(no)}
420 assert md == {}
421 assert catcher == []
422
418 423 d, md = f.format(yes)
419 nt.assert_equal(d, {})
420 nt.assert_equal(md, {})
421 nt.assert_equal(catcher, [yes])
424 assert d == {}
425 assert md == {}
426 assert catcher == [yes]
422 427
423 428 f.ipython_display_formatter.enabled = save_enabled
424 429
@@ -431,8 +436,8 b' def test_json_as_string_deprecated():'
431 436 f = JSONFormatter()
432 437 with warnings.catch_warnings(record=True) as w:
433 438 d = f(JSONString())
434 nt.assert_equal(d, {})
435 nt.assert_equal(len(w), 1)
439 assert d == {}
440 assert len(w) == 1
436 441
437 442
438 443 def test_repr_mime():
@@ -458,19 +463,22 b' def test_repr_mime():'
458 463 obj = HasReprMime()
459 464 d, md = f.format(obj)
460 465 html_f.enabled = save_enabled
461
462 nt.assert_equal(sorted(d), ['application/json+test.v2',
463 'image/png',
464 'plain/text',
465 'text/html',
466 'text/plain'])
467 nt.assert_equal(md, {})
468 466
469 d, md = f.format(obj, include={'image/png'})
470 nt.assert_equal(list(d.keys()), ['image/png'],
471 'Include should filter out even things from repr_mimebundle')
472 nt.assert_equal(d['image/png'], 'i-overwrite', '_repr_mimebundle_ take precedence')
467 assert sorted(d) == [
468 "application/json+test.v2",
469 "image/png",
470 "plain/text",
471 "text/html",
472 "text/plain",
473 ]
474 assert md == {}
473 475
476 d, md = f.format(obj, include={"image/png"})
477 assert list(d.keys()) == [
478 "image/png"
479 ], "Include should filter out even things from repr_mimebundle"
480
481 assert d["image/png"] == "i-overwrite", "_repr_mimebundle_ take precedence"
474 482
475 483
476 484 def test_pass_correct_include_exclude():
@@ -514,13 +522,14 b' def test_repr_mime_meta():'
514 522 f = get_ipython().display_formatter
515 523 obj = HasReprMimeMeta()
516 524 d, md = f.format(obj)
517 nt.assert_equal(sorted(d), ['image/png', 'text/plain'])
518 nt.assert_equal(md, {
519 'image/png': {
520 'width': 5,
521 'height': 10,
525 assert sorted(d) == ["image/png", "text/plain"]
526 assert md == {
527 "image/png": {
528 "width": 5,
529 "height": 10,
522 530 }
523 })
531 }
532
524 533
525 534 def test_repr_mime_failure():
526 535 class BadReprMime(object):
@@ -530,4 +539,4 b' def test_repr_mime_failure():'
530 539 f = get_ipython().display_formatter
531 540 obj = BadReprMime()
532 541 d, md = f.format(obj)
533 nt.assert_in('text/plain', d)
542 assert "text/plain" in d
General Comments 0
You need to be logged in to leave comments. Login now