(fig_test, fig_ref)
| 225 | |
| 226 | @check_figures_equal() |
| 227 | def 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 | |
| 257 | def test_table_dataframe(pd): |
nothing calls this directly
no test coverage detected
searching dependent graphs…