File tree Expand file tree Collapse file tree 9 files changed +31
-17
lines changed
Filter options
Expand file tree Collapse file tree 9 files changed +31
-17
lines changed
Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ environment:
16
16
global :
17
17
PYTHONIOENCODING : UTF-8
18
18
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
20
20
21
21
matrix :
22
22
# theoretically the CONDA_INSTALL_LOCN could be only two: one for 32bit,
Original file line number Diff line number Diff line change
1
+ API changes
2
+ ```````````
3
+
4
+ The ``--no-network `` flag to ``tests.py `` has been removed (no test requires
5
+ internet access anymore). If it is desired to disable internet access both for
6
+ old and new versions of Matplotlib, use ``tests.py -m 'not network' `` (which is
7
+ now a no-op).
Original file line number Diff line number Diff line change @@ -54,7 +54,6 @@ commands, such as:
54
54
55
55
======================== ===========
56
56
``--pep8 `` Perform pep8 checks (requires pytest-pep8 _)
57
- ``-m "not network" `` Disable tests that require network access
58
57
======================== ===========
59
58
60
59
Additional arguments are passed on to pytest. See the pytest documentation for
Original file line number Diff line number Diff line change @@ -867,7 +867,7 @@ def rc_params(fail_on_error=False):
867
867
return rc_params_from_file (matplotlib_fname (), fail_on_error )
868
868
869
869
870
- URL_REGEX = re .compile (r'http://|https://|ftp://|file://|file:\\ ' )
870
+ URL_REGEX = re .compile (r'^ http://|^ https://|^ ftp://|^ file:' )
871
871
872
872
873
873
def is_url (filename ):
Original file line number Diff line number Diff line change @@ -1379,12 +1379,20 @@ def read_png(*args, **kwargs):
1379
1379
if format is None :
1380
1380
if isinstance (fname , str ):
1381
1381
parsed = urllib .parse .urlparse (fname )
1382
- # If the string is a URL, assume png
1382
+ # If the string is a URL (Windows paths appear as if they have a
1383
+ # length-1 scheme), assume png.
1383
1384
if len (parsed .scheme ) > 1 :
1384
1385
ext = 'png'
1385
1386
else :
1386
1387
basename , ext = os .path .splitext (fname )
1387
1388
ext = ext .lower ()[1 :]
1389
+ elif hasattr (fname , 'geturl' ): # Returned by urlopen().
1390
+ # We could try to parse the url's path and use the extension, but
1391
+ # returning png is consistent with the block above. Note that this
1392
+ # if clause has to come before checking for fname.name as
1393
+ # urlopen("file:///...") also has a name attribute (with the fixed
1394
+ # value "<urllib response>").
1395
+ ext = 'png'
1388
1396
elif hasattr (fname , 'name' ):
1389
1397
basename , ext = os .path .splitext (fname .name )
1390
1398
ext = ext .lower ()[1 :]
Original file line number Diff line number Diff line change 5
5
import sys
6
6
from pathlib import Path
7
7
import platform
8
+ import sys
8
9
import urllib .request
9
10
import warnings
10
11
@@ -657,9 +658,11 @@ def test_minimized_rasterized():
657
658
assert False
658
659
659
660
660
- @pytest .mark .network
661
661
def test_load_from_url ():
662
- url = "http://matplotlib.org/_static/logo_sidebar_horiz.png"
662
+ path = Path (__file__ ).parent / "baseline_images/test_image/imshow.png"
663
+ url = ('file:'
664
+ + ('///' if sys .platform == 'win32' else '' )
665
+ + path .resolve ().as_posix ())
663
666
plt .imread (url )
664
667
plt .imread (urllib .request .urlopen (url ))
665
668
Original file line number Diff line number Diff line change 3
3
import gc
4
4
from pathlib import Path
5
5
from tempfile import TemporaryDirectory
6
+ import sys
6
7
7
8
import pytest
8
9
@@ -56,10 +57,14 @@ def test_use():
56
57
assert mpl .rcParams [PARAM ] == VALUE
57
58
58
59
59
- @pytest .mark .network
60
- def test_use_url ():
60
+ def test_use_url (tmpdir ):
61
+ path = Path (tmpdir , 'file' )
62
+ path .write_text ('axes.facecolor: adeade' )
61
63
with temp_style ('test' , DUMMY_SETTINGS ):
62
- with style .context ('https://gist.github.com/adrn/6590261/raw' ):
64
+ url = ('file:'
65
+ + ('///' if sys .platform == 'win32' else '' )
66
+ + path .resolve ().as_posix ())
67
+ with style .context (url ):
63
68
assert mpl .rcParams ['axes.facecolor' ] == "#adeade"
64
69
65
70
Original file line number Diff line number Diff line change @@ -6,5 +6,4 @@ python_files = test_*.py
6
6
7
7
markers =
8
8
backend: Set alternate Matplotlib backend temporarily.
9
- network: Mark a test that uses the network.
10
9
style: Set alternate Matplotlib style temporarily.
Original file line number Diff line number Diff line change 39
39
from matplotlib import test
40
40
41
41
parser = argparse .ArgumentParser (add_help = False )
42
- parser .add_argument ('--no-network' , action = 'store_true' ,
43
- help = 'Run tests without network connection' )
44
42
parser .add_argument ('--recursionlimit' , type = int , default = 0 ,
45
43
help = 'Specify recursionlimit for test run' )
46
44
args , extra_args = parser .parse_known_args ()
47
45
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
-
53
46
print ('Python byte-compilation optimization level:' , sys .flags .optimize )
54
47
55
48
retcode = test (argv = extra_args , switch_backend_warn = False ,
You can’t perform that action at this time.
0 commit comments