8000 Don't access internet during tests. · matplotlib/matplotlib@31ce662 · GitHub
[go: up one dir, main page]

Skip to content

Commit 31ce662

Browse files
committed
Don't access internet during tests.
The tests that style.use() and imread() support urls can just use local urls (`file://`); this avoids failing the tests when downloading the gist fails due to a flaky connection.
1 parent af80d57 commit 31ce662

File tree

6 files changed

+7
-15
lines changed

6 files changed

+7
-15
lines changed

.appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ environment:
1616
global:
1717
PYTHONIOENCODING: UTF-8
1818
PYTEST_ARGS: -raR --numprocesses=auto --timeout=300 --durations=25
19-
--cov-report= --cov=lib -m "not network" --log-level=DEBUG
19+
--cov-report= --cov=lib --log-level=DEBUG
2020

2121
matrix:
2222
# theoretically the CONDA_INSTALL_LOCN could be only two: one for 32bit,

doc/devel/testing.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ commands, such as:
5454

5555
======================== ===========
5656
``--pep8`` Perform pep8 checks (requires pytest-pep8_)
57-
``-m "not network"`` Disable tests that require network access
5857
======================== ===========
5958

6059
Additional arguments are passed on to pytest. See the pytest documentation for

lib/matplotlib/tests/test_image.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -657,9 +657,9 @@ def test_minimized_rasterized():
657657
assert False
658658

659659

660-
@pytest.mark.network
661660
def test_load_from_url():
662-
url = "http://matplotlib.org/_static/logo_sidebar_horiz.png"
661+
path = Path(__file__).parent / "baseline_images/test_image/imshow.png"
662+
url = f"file://{path.resolve().as_posix()}"
663663
plt.imread(url)
664664
plt.imread(urllib.request.urlopen(url))
665665

lib/matplotlib/tests/test_style.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,11 @@ def test_use():
5656
assert mpl.rcParams[PARAM] == VALUE
5757

5858

59-
@pytest.mark.network
60-
def test_use_url():
59+
def test_use_url(tmpdir):
60+
path = Path(tmpdir, 'file')
61+
path.write_text('axes.facecolor: adeade')
6162
with temp_style('test', DUMMY_SETTINGS):
62-
with style.context('https://gist.github.com/adrn/6590261/raw'):
63+
with style.context(f'file://{path.resolve().as_posix()}'):
6364
assert mpl.rcParams['axes.facecolor'] == "#adeade"
6465

6566

pytest.ini

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,4 @@ python_files = test_*.py
66

77
markers =
88
backend: Set alternate Matplotlib backend temporarily.
9-
network: Mark a test that uses the network.
109
style: Set alternate Matplotlib style temporarily.

tests.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,10 @@
3939
from matplotlib import test
4040

4141
parser = argparse.ArgumentParser(add_help=False)
42-
parser.add_argument('--no-network', action='store_true',
43-
help='Run tests without network connection')
4442
parser.add_argument('--recursionlimit', type=int, default=0,
4543
help='Specify recursionlimit for test run')
4644
args, extra_args = parser.parse_known_args()
4745

48-
if args.no_network:
49-
from matplotlib.testing import disable_internet
50-
disable_internet.turn_off_internet()
51-
extra_args.extend(['-m', 'not network'])
52-
5346
print('Python byte-compilation optimization level:', sys.flags.optimize)
5447

5548
retcode = test(argv=extra_args, switch_backend_warn=False,

0 commit comments

Comments
 (0)
0