@@ -135,12 +135,13 @@ def test_date_axvline():
135135 fig .autofmt_xdate ()
136136
137137
138- def test_too_many_date_ticks ():
138+ def test_too_many_date_ticks (caplog ):
139139 # Attempt to test SF 2715172, see
140140 # https://sourceforge.net/tracker/?func=detail&aid=2715172&group_id=80706&atid=560720
141141 # setting equal datetimes triggers and expander call in
142142 # transforms.nonsingular which results in too many ticks in the
143- # DayLocator. This should trigger a Locator.MAXTICKS RuntimeError
143+ # DayLocator. This should emit a log at WARNING level.
144+ caplog .set_level ("WARNING" )
144145 t0 = datetime .datetime (2000 , 1 , 20 )
145146 tf = datetime .datetime (2000 , 1 , 20 )
146147 fig = plt .figure ()
@@ -152,8 +153,13 @@ def test_too_many_date_ticks():
152153 'Attempting to set identical left == right' in str (rec [0 ].message )
153154 ax .plot ([], [])
154155 ax .xaxis .set_major_locator (mdates .DayLocator ())
155- with pytest .raises (RuntimeError ):
156- fig .savefig ('junk.png' )
156+ fig .canvas .draw ()
157+ # The warning is emitted multiple times because the major locator is also
158+ # called both when placing the minor ticks (for overstriking detection) and
159+ # during tick label positioning.
160+ assert caplog .records and all (
161+ record .name == "matplotlib.ticker" and record .levelname == "WARNING"
162+ for record in caplog .records )
157163
158164
159165@image_comparison (['RRuleLocator_bounds.png' ])
0 commit comments