Skip to content

Commit 771707f

Browse files
authored
Merge pull request #6923 from astrofrog/nose-optional
MNT: Make sure nose is only imported when needed
2 parents 7d25ee8 + 360b8c0 commit 771707f

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

lib/matplotlib/testing/decorators.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@
1212
import warnings
1313
import unittest
1414

15-
import nose
15+
# Note - don't import nose up here - import it only as needed in functions. This
16+
# allows other functions here to be used by pytest-based testing suites without
17+
# requiring nose to be installed.
18+
1619
import numpy as np
1720

1821
import matplotlib as mpl
@@ -417,6 +420,9 @@ def find_dotted_module(module_name, path=None):
417420

418421

419422
def switch_backend(backend):
423+
# Local import to avoid a hard nose dependency and only incur the
424+
# import time overhead at actual test-time.
425+
import nose
420426
def switch_backend_decorator(func):
421427
def backend_switcher(*args, **kwargs):
422428
try:

0 commit comments

Comments
 (0)