| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -369,6 +369,8 @@ def bin_path(cls): | |||
| 369 | 369 | @classmethod | |
| 370 | 370 | def isAvailable(cls): | |
| 371 | 371 | """Return whether a MovieWriter subclass is actually available.""" | |
| 372 | + if sys.platform == 'emscripten': | ||
| 373 | + return False | ||
| 372 | 374 | return shutil.which(cls.bin_path()) is not None | |
| 373 | 375 | ||
| 374 | 376 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1297,7 +1297,7 @@ def find_tex_file(filename): | |||
| 1297 | 1297 | ||
| 1298 | 1298 | try: | |
| 1299 | 1299 | lk = _LuatexKpsewhich() | |
| 1300 | - except FileNotFoundError: | ||
| 1300 | + except (FileNotFoundError, OSError): | ||
| 1301 | 1301 | lk = None # Fallback to directly calling kpsewhich, as below. | |
| 1302 | 1302 | ||
| 1303 | 1303 | if lk: | |
@@ -1320,7 +1320,7 @@ def find_tex_file(filename): | |||
| 1320 | 1320 | path = cbook._check_and_log_subprocess( | |
| 1321 | 1321 | ['kpsewhich', '-mktex=pk', filename], _log, **kwargs, | |
| 1322 | 1322 | ).rstrip('\n') | |
| 1323 | - except (FileNotFoundError, RuntimeError): | ||
| 1323 | + except (FileNotFoundError, OSError, RuntimeError): | ||
| 1324 | 1324 | path = None | |
| 1325 | 1325 | ||
| 1326 | 1326 | if path: | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -87,9 +87,14 @@ def subprocess_run_for_testing(command, env=None, timeout=60, stdout=None, | |||
| 87 | 87 | ||
| 88 | 88 | Raises | |
| 89 | 89 | ------ | |
| 90 | + pytest.skip | ||
| 91 | + If running on emscripten, which does not support subprocesses. | ||
| 90 | 92 | pytest.xfail | |
| 91 | 93 | If platform is Cygwin and subprocess reports a fork() failure. | |
| 92 | 94 | """ | |
| 95 | + if sys.platform == 'emscripten': | ||
| 96 | + import pytest | ||
| 97 | + pytest.skip('emscripten does not support subprocesses') | ||
| 93 | 98 | if capture_output: | |
| 94 | 99 | stdout = stderr = subprocess.PIPE | |
| 95 | 100 | # Add CREATE_NO_WINDOW flag on Windows to prevent console window overhead | |
@@ -208,7 +213,7 @@ def _has_tex_package(package): | |||
| 208 | 213 | try: | |
| 209 | 214 | mpl.dviread.find_tex_file(f"{package}.sty") | |
| 210 | 215 | return True | |
| 211 | - except FileNotFoundError: | ||
| 216 | + except (FileNotFoundError, OSError): | ||
| 212 | 217 | return False | |
| 213 | 218 | ||
| 214 | 219 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -139,6 +139,8 @@ def copy_baseline(self, baseline, extension): | |||
| 139 | 139 | try: | |
| 140 | 140 | if 'microsoft' in uname().release.lower(): | |
| 141 | 141 | raise OSError # On WSL, symlink breaks silently | |
| 142 | + if sys.platform == 'emscripten': | ||
| 143 | + raise OSError | ||
| 142 | 144 | os.symlink(orig_expected_path, expected_fname) | |
| 143 | 145 | except OSError: # On Windows, symlink *may* be unavailable. | |
| 144 | 146 | shutil.copyfile(orig_expected_path, expected_fname) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -271,6 +271,8 @@ def test_no_length_frames(anim): | |||
| 271 | 271 | anim.save('unused.null', writer=NullMovieWriter()) | |
| 272 | 272 | ||
| 273 | 273 | ||
| 274 | + @pytest.mark.skipif(sys.platform == 'emscripten', | ||
| 275 | + reason='emscripten does not support subprocesses') | ||
| 274 | 276 | def test_movie_writer_registry(): | |
| 275 | 277 | assert len(animation.writers._registered) > 0 | |
| 276 | 278 | mpl.rcParams['animation.ffmpeg_path'] = "not_available_ever_xxxx" | |
@@ -522,6 +524,8 @@ def test_disable_cache_warning(anim): | |||
| 522 | 524 | def test_movie_writer_invalid_path(anim): | |
| 523 | 525 | if sys.platform == "win32": | |
| 524 | 526 | match_str = r"\[WinError 3] .*\\\\foo\\\\bar\\\\aardvark'" | |
| 527 | + elif sys.platform == "emscripten": | ||
| 528 | + match_str = r"\[Errno 44] .*'/foo" | ||
| 525 | 529 | else: | |
| 526 | 530 | match_str = r"\[Errno 2] .*'/foo" | |
| 527 | 531 | with pytest.raises(FileNotFoundError, match=match_str): | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,6 +1,7 @@ | |||
| 1 | 1 | import json | |
| 2 | 2 | from pathlib import Path | |
| 3 | 3 | import shutil | |
| 4 | + import sys | ||
| 4 | 5 | ||
| 5 | 6 | from matplotlib import cbook, dviread as dr | |
| 6 | 7 | from matplotlib.testing import subprocess_run_for_testing, _has_tex_package | |
@@ -61,7 +62,7 @@ def test_PsfontsMap(monkeypatch): | |||
| 61 | 62 | fontmap[b'%'] | |
| 62 | 63 | ||
| 63 | 64 | ||
| 64 | - @pytest.mark.skipif(shutil.which("kpsewhich") is None, | ||
| 65 | + @pytest.mark.skipif(sys.platform == "emscripten" or shutil.which("kpsewhich") is None, | ||
| 65 | 66 | reason="kpsewhich is not available") | |
| 66 | 67 | @pytest.mark.parametrize("engine", ["pdflatex", "xelatex", "lualatex"]) | |
| 67 | 68 | def test_dviread(tmp_path, engine, monkeypatch): | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -3,6 +3,7 @@ | |||
| 3 | 3 | import io | |
| 4 | 4 | import pickle | |
| 5 | 5 | import platform | |
| 6 | + import sys | ||
| 6 | 7 | from threading import Timer | |
| 7 | 8 | from types import SimpleNamespace | |
| 8 | 9 | import warnings | |
@@ -1629,6 +1630,8 @@ def test_add_axes_kwargs(): | |||
| 1629 | 1630 | plt.close() | |
| 1630 | 1631 | ||
| 1631 | 1632 | ||
| 1633 | + @pytest.mark.skipif(sys.platform == 'emscripten', | ||
| 1634 | + reason='emscripten does not support threads') | ||
| 1632 | 1635 | def test_ginput(recwarn): # recwarn undoes warn filters at exit. | |
| 1633 | 1636 | warnings.filterwarnings("ignore", "cannot show the figure") | |
| 1634 | 1637 | fig, ax = plt.subplots() | |
@@ -1651,6 +1654,8 @@ def multi_presses(): | |||
| 1651 | 1654 | np.testing.assert_allclose(fig.ginput(3), [(.3, .4), (.5, .6)]) | |
| 1652 | 1655 | ||
| 1653 | 1656 | ||
| 1657 | + @pytest.mark.skipif(sys.platform == 'emscripten', | ||
| 1658 | + reason='emscripten does not support threads') | ||
| 1654 | 1659 | def test_waitforbuttonpress(recwarn): # recwarn undoes warn filters at exit. | |
| 1655 | 1660 | warnings.filterwarnings("ignore", "cannot show the figure") | |
| 1656 | 1661 | fig = plt.figure() | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -229,6 +229,8 @@ def _model_handler(_): | |||
| 229 | 229 | plt.close() | |
| 230 | 230 | ||
| 231 | 231 | ||
| 232 | + @pytest.mark.skipif(sys.platform == 'emscripten', | ||
| 233 | + reason='emscripten does not support subprocesses') | ||
| 232 | 234 | @pytest.mark.skipif(not hasattr(os, "register_at_fork"), | |
| 233 | 235 | reason="Cannot register at_fork handlers") | |
| 234 | 236 | def test_fork(): | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -258,10 +258,6 @@ def _run_checked_subprocess(cls, command, tex, *, cwd=None): | |||
| 258 | 258 | report = subprocess.check_output( | |
| 259 | 259 | command, cwd=cwd if cwd is not None else cls._cache_dir, | |
| 260 | 260 | stderr=subprocess.STDOUT) | |
| 261 | - except FileNotFoundError as exc: | ||
| 262 | - raise RuntimeError( | ||
| 263 | - f'Failed to process string with tex because {command[0]} ' | ||
| 264 | - 'could not be found') from exc | ||
| 265 | 261 | except subprocess.CalledProcessError as exc: | |
| 266 | 262 | raise RuntimeError( | |
| 267 | 263 | '{prog} was not able to process the following string:\n' | |
@@ -274,6 +270,10 @@ def _run_checked_subprocess(cls, command, tex, *, cwd=None): | |||
| 274 | 270 | tex=tex.encode('unicode_escape'), | |
| 275 | 271 | exc=exc.output.decode('utf-8', 'backslashreplace')) | |
| 276 | 272 | ) from None | |
| 273 | + except (FileNotFoundError, OSError) as exc: | ||
| 274 | + raise RuntimeError( | ||
| 275 | + f'Failed to process string with tex because {command[0]} ' | ||
| 276 | + 'could not be found') from exc | ||
| 277 | 277 | _log.debug(report) | |
| 278 | 278 | return report | |
| 279 | 279 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments