(caplog)
| 189 | |
| 190 | |
| 191 | def test_too_many_date_ticks(caplog): |
| 192 | # Attempt to test SF 2715172, see |
| 193 | # https://sourceforge.net/tracker/?func=detail&aid=2715172&group_id=80706&atid=560720 |
| 194 | # setting equal datetimes triggers and expander call in |
| 195 | # transforms.nonsingular which results in too many ticks in the |
| 196 | # DayLocator. This should emit a log at WARNING level. |
| 197 | caplog.set_level("WARNING") |
| 198 | t0 = datetime.datetime(2000, 1, 20) |
| 199 | tf = datetime.datetime(2000, 1, 20) |
| 200 | fig, ax = plt.subplots() |
| 201 | with pytest.warns(UserWarning) as rec: |
| 202 | ax.set_xlim(t0, tf, auto=True) |
| 203 | assert len(rec) == 1 |
| 204 | assert ('Attempting to set identical low and high xlims' |
| 205 | in str(rec[0].message)) |
| 206 | ax.plot([], []) |
| 207 | ax.xaxis.set_major_locator(mdates.DayLocator()) |
| 208 | v = ax.xaxis.get_major_locator()() |
| 209 | assert len(v) > 1000 |
| 210 | # The warning is emitted multiple times because the major locator is also |
| 211 | # called both when placing the minor ticks (for overstriking detection) and |
| 212 | # during tick label positioning. |
| 213 | assert caplog.records and all( |
| 214 | record.name == "matplotlib.ticker" and record.levelname == "WARNING" |
| 215 | for record in caplog.records) |
| 216 | assert len(caplog.records) > 0 |
| 217 | |
| 218 | |
| 219 | def _new_epoch_decorator(thefunc): |
nothing calls this directly
no test coverage detected
searching dependent graphs…