Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 297921a

Browse files
committed
Make test_change_epoch more robust.
The epoch is set by explicitly calling `mdates.set_epoch`, or implicitly set to the default by `mdates.get_epoch` (which is also called when converting datetimes.) However, when running tests in parallel, there is no guarantee that any other call to `[gs]et_epoch` might have been made to lock it in, so we need to do that explicitly.
1 parent 030ca97 commit 297921a

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

lib/matplotlib/tests/test_dates.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1095,12 +1095,15 @@ def test_datetime64_in_list():
10951095
def test_change_epoch():
10961096
date = np.datetime64('2000-01-01')
10971097

1098+
# use private method to clear the epoch and allow it to be set...
1099+
mdates._reset_epoch_test_example()
1100+
mdates.get_epoch() # Set default.
1101+
10981102
with pytest.raises(RuntimeError):
10991103
# this should fail here because there is a sentinel on the epoch
11001104
# if the epoch has been used then it cannot be set.
11011105
mdates.set_epoch('0000-01-01')
11021106

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

0 commit comments

Comments
 (0)