MCPcopy Create free account
hub / github.com/ipython/ipython / test_print_method_weird

Function test_print_method_weird

IPython/core/tests/test_formatters.py:327–362  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

325 nt.assert_equal(captured.stderr, "")
326
327def test_print_method_weird():
328
329 class TextMagicHat(object):
330 def __getattr__(self, key):
331 return key
332
333 f = HTMLFormatter()
334
335 text_hat = TextMagicHat()
336 nt.assert_equal(text_hat._repr_html_, '_repr_html_')
337 with capture_output() as captured:
338 result = f(text_hat)
339
340 nt.assert_is(result, None)
341 nt.assert_not_in("FormatterWarning", captured.stderr)
342
343 class CallableMagicHat(object):
344 def __getattr__(self, key):
345 return lambda : key
346
347 call_hat = CallableMagicHat()
348 with capture_output() as captured:
349 result = f(call_hat)
350
351 nt.assert_equal(result, None)
352
353 class BadReprArgs(object):
354 def _repr_html_(self, extra, args):
355 return "html"
356
357 bad = BadReprArgs()
358 with capture_output() as captured:
359 result = f(bad)
360
361 nt.assert_is(result, None)
362 nt.assert_not_in("FormatterWarning", captured.stderr)
363
364
365def 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