Skip to content

Commit

Permalink
Merge pull request #20817 from QuLogic/robust-change-epoch
Browse files Browse the repository at this point in the history
Make test_change_epoch more robust.
  • Loading branch information
timhoffm committed Aug 10, 2021
2 parents b61e76a + 297921a commit 3d5027d
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/matplotlib/tests/test_dates.py
Expand Up @@ -1095,12 +1095,15 @@ def test_datetime64_in_list():
def test_change_epoch():
date = np.datetime64('2000-01-01')

# use private method to clear the epoch and allow it to be set...
mdates._reset_epoch_test_example()
mdates.get_epoch() # Set default.

with pytest.raises(RuntimeError):
# this should fail here because there is a sentinel on the epoch
# if the epoch has been used then it cannot be set.
mdates.set_epoch('0000-01-01')

# use private method to clear the epoch and allow it to be set...
mdates._reset_epoch_test_example()
mdates.set_epoch('1970-01-01')
dt = (date - np.datetime64('1970-01-01')).astype('datetime64[D]')
Expand Down

0 comments on commit 3d5027d

Please sign in to comment.