Skip to content

Commit 4e5d83e

Browse files
authored
Merge pull request #14345 from anntzer/importorskip
Use importorskip for tests depending on pytz.
2 parents a930461 + c0a625e commit 4e5d83e

File tree

1 file changed

+2
-12
lines changed

1 file changed

+2
-12
lines changed

lib/matplotlib/tests/test_dates.py

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,6 @@
1515
from matplotlib import rc_context
1616

1717

18-
def __has_pytz():
19-
try:
20-
import pytz
21-
return True
22-
except ImportError:
23-
return False
24-
25-
2618
def test_date_numpyx():
2719
# test that numpy dates work properly...
2820
base = datetime.datetime(2017, 1, 1)
@@ -710,10 +702,9 @@ def attach_tz(dt, zi):
710702

711703

712704
@pytest.mark.pytz
713-
@pytest.mark.skipif(not __has_pytz(), reason="Requires pytz")
714705
def test_rrulewrapper_pytz():
715706
# Test to make sure pytz zones are supported in rrules
716-
import pytz
707+
pytz = pytest.importorskip("pytz")
717708

718709
def attach_tz(dt, zi):
719710
return zi.localize(dt)
@@ -722,9 +713,8 @@ def attach_tz(dt, zi):
722713

723714

724715
@pytest.mark.pytz
725-
@pytest.mark.skipif(not __has_pytz(), reason="Requires pytz")
726716
def test_yearlocator_pytz():
727-
import pytz
717+
pytz = pytest.importorskip("pytz")
728718

729719
tz = pytz.timezone('America/New_York')
730720
x = [tz.localize(datetime.datetime(2010, 1, 1))

0 commit comments

Comments
 (0)