MCPcopy Index your code
hub / github.com/ipython/ipython / test_print_method_weird

Function test_print_method_weird

tests/test_formatters.py:397–431  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

395
396
397def test_print_method_weird():
398 class TextMagicHat(object):
399 def __getattr__(self, key):
400 return key
401
402 f = HTMLFormatter()
403
404 text_hat = TextMagicHat()
405 assert text_hat._repr_html_ == "_repr_html_"
406 with capture_output() as captured:
407 result = f(text_hat)
408
409 assert result is None
410 assert "FormatterWarning" not in captured.stderr
411
412 class CallableMagicHat(object):
413 def __getattr__(self, key):
414 return lambda: key
415
416 call_hat = CallableMagicHat()
417 with capture_output() as captured:
418 result = f(call_hat)
419
420 assert result is None
421
422 class BadReprArgs(object):
423 def _repr_html_(self, extra, args):
424 return "html"
425
426 bad = BadReprArgs()
427 with capture_output() as captured:
428 result = f(bad)
429
430 assert result is None
431 assert "FormatterWarning" not in captured.stderr
432
433
434def test_format_config():

Callers

nothing calls this directly

Calls 6

HTMLFormatterClass · 0.90
TextMagicHatClass · 0.85
capture_outputClass · 0.85
CallableMagicHatClass · 0.85
BadReprArgsClass · 0.85
fFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…