python-matplotlib/0007-Make-test_change_epoch-more-robust.patch

43 lines
1.6 KiB
Diff
Raw Normal View History

2021-08-10 05:34:04 +00:00
From 227aacf576f6fce253673ce05365db11dfa6df7d Mon Sep 17 00:00:00 2001
From: Elliott Sales de Andrade <quantum.analyst@gmail.com>
Date: Tue, 10 Aug 2021 00:45:07 -0400
Subject: [PATCH 7/7] 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.
Signed-off-by: Elliott Sales de Andrade <quantum.analyst@gmail.com>
---
lib/matplotlib/tests/test_dates.py | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/lib/matplotlib/tests/test_dates.py b/lib/matplotlib/tests/test_dates.py
index 8c821c0da5..36449e44aa 100644
--- a/lib/matplotlib/tests/test_dates.py
+++ b/lib/matplotlib/tests/test_dates.py
@@ -1004,12 +1004,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]')
--
2.31.1