MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / test_table_unit

Function test_table_unit

lib/matplotlib/tests/test_table.py:227–254  ·  view source on GitHub ↗
(fig_test, fig_ref)

Source from the content-addressed store, hash-verified

225
226@check_figures_equal()
227def test_table_unit(fig_test, fig_ref):
228 # test that table doesn't participate in unit machinery, instead uses repr/str
229
230 class FakeUnit:
231 def __init__(self, thing):
232 pass
233 def __repr__(self):
234 return "Hello"
235
236 fake_convertor = munits.ConversionInterface()
237 # v, u, a = value, unit, axis
238 fake_convertor.convert = Mock(side_effect=lambda v, u, a: 0)
239 # not used, here for completeness
240 fake_convertor.default_units = Mock(side_effect=lambda v, a: None)
241 fake_convertor.axisinfo = Mock(side_effect=lambda u, a: munits.AxisInfo())
242
243 munits.registry[FakeUnit] = fake_convertor
244
245 data = [[FakeUnit("yellow"), FakeUnit(42)],
246 [FakeUnit(datetime.datetime(1968, 8, 1)), FakeUnit(True)]]
247
248 fig_test.subplots().table(data)
249 fig_ref.subplots().table([["Hello", "Hello"], ["Hello", "Hello"]])
250 fig_test.canvas.draw()
251 fake_convertor.convert.assert_not_called()
252
253 munits.registry.pop(FakeUnit)
254 assert not munits.registry.get_converter(FakeUnit)
255
256
257def test_table_dataframe(pd):

Callers

nothing calls this directly

Calls 5

FakeUnitClass · 0.85
subplotsMethod · 0.45
drawMethod · 0.45
popMethod · 0.45
get_converterMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…