From a4907839dd5c354f17f2f520708cf8b20ab34ca5 Mon Sep 17 00:00:00 2001 From: Roman Yurchak Date: Tue, 9 Feb 2021 23:39:07 +0100 Subject: [PATCH] TST xfail the pillow test that fails on Chrome (#1222) --- packages/pandas/test_pandas.py | 7 ----- packages/pillow/test_pillow.py | 32 ++++++++++++---------- packages/scikit-learn/test_scikit-learn.py | 2 -- packages/scipy/test_scipy.py | 3 -- packages/test_common.py | 29 ++------------------ 5 files changed, 20 insertions(+), 53 deletions(-) diff --git a/packages/pandas/test_pandas.py b/packages/pandas/test_pandas.py index ac3b54e71..9b45a3fe0 100644 --- a/packages/pandas/test_pandas.py +++ b/packages/pandas/test_pandas.py @@ -35,15 +35,11 @@ def generate_largish_json(n_rows: int = 91746) -> Dict: def test_pandas(selenium, request): - if selenium.browser == "chrome": - request.applymarker(pytest.mark.xfail(run=False, reason="chrome not supported")) selenium.load_package("pandas") assert len(selenium.run("import pandas\ndir(pandas)")) == 142 def test_extra_import(selenium, request): - if selenium.browser == "chrome": - request.applymarker(pytest.mark.xfail(run=False, reason="chrome not supported")) selenium.load_package("pandas") selenium.run("from pandas import Series, DataFrame, Panel") @@ -52,9 +48,6 @@ def test_extra_import(selenium, request): def test_load_largish_file(selenium_standalone, request, httpserver): selenium = selenium_standalone - if selenium.browser == "chrome": - request.applymarker(pytest.mark.xfail(run=False, reason="chrome not supported")) - selenium.load_package("pandas") selenium.load_package("matplotlib") diff --git a/packages/pillow/test_pillow.py b/packages/pillow/test_pillow.py index d201086eb..3d4c4a6e6 100644 --- a/packages/pillow/test_pillow.py +++ b/packages/pillow/test_pillow.py @@ -1,6 +1,8 @@ +import pytest from pyodide_build.testing import run_in_pyodide +@pytest.mark.xfail @run_in_pyodide(packages=["pillow"]) def test_pillow(): from PIL import Image, ImageDraw, ImageOps @@ -16,17 +18,19 @@ def test_pillow(): img.tobytes() == b"\xff\x00\x00\xff\x00\x00\xff\x00\x00\xff\x00\x00\xff\x00\x00\x00\x00\x00\x00\x00\xff\xff\x00\x00\xff\x00\x00\x00\xff\x00\x00\x00\x00\xff\x00\x00\xff\x00\x00\xff\x00\x00\xff\x00\x00\xff\x00\x00" ) - byio = io.BytesIO() - img.save(byio, format="PNG") - assert ( - byio.getvalue() - == b"\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\x04\x00\x00\x00\x04\x08\x02\x00\x00\x00&\x93\t)\x00\x00\x00\x1cIDATx\x9cc\xfc\xcf\x80\x04`\x9c\xff\xff\x19\x18\x98`\x02\x8c\x0c\x0c\x0c\x8c\xc8\xca\x00\xb5\x05\x06\x00\xcbi8B\x00\x00\x00\x00IEND\xaeB`\x82" - ) - img = Image.open(byio) - assert ( - img.tobytes() - == b"\xff\x00\x00\xff\x00\x00\xff\x00\x00\xff\x00\x00\xff\x00\x00\x00\x00\x00\x00\x00\xff\xff\x00\x00\xff\x00\x00\x00\xff\x00\x00\x00\x00\xff\x00\x00\xff\x00\x00\xff\x00\x00\xff\x00\x00\xff\x00\x00" - ) - asjpg = io.BytesIO() - img.save(asjpg, format="JPEG") - img = Image.open(asjpg) + with io.BytesIO() as byio: + img.save(byio, format="PNG") + + assert ( + byio.getvalue() + == b"\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\x04\x00\x00\x00\x04\x08\x02\x00\x00\x00&\x93\t)\x00\x00\x00\x1cIDATx\x9cc\xfc\xcf\x80\x04`\x9c\xff\xff\x19\x18\x98`\x02\x8c\x0c\x0c\x0c\x8c\xc8\xca\x00\xb5\x05\x06\x00\xcbi8B\x00\x00\x00\x00IEND\xaeB`\x82" + ) + img = Image.open(byio) + assert ( + img.tobytes() + == b"\xff\x00\x00\xff\x00\x00\xff\x00\x00\xff\x00\x00\xff\x00\x00\x00\x00\x00\x00\x00\xff\xff\x00\x00\xff\x00\x00\x00\xff\x00\x00\x00\x00\xff\x00\x00\xff\x00\x00\xff\x00\x00\xff\x00\x00\xff\x00\x00" + ) + + with io.BytesIO() as asjpg: + img.save(asjpg, format="JPEG") + img = Image.open(asjpg) diff --git a/packages/scikit-learn/test_scikit-learn.py b/packages/scikit-learn/test_scikit-learn.py index 1bed25f53..1bed7a50a 100644 --- a/packages/scikit-learn/test_scikit-learn.py +++ b/packages/scikit-learn/test_scikit-learn.py @@ -3,8 +3,6 @@ import pytest def test_scikit_learn(selenium_standalone, request): selenium = selenium_standalone - if selenium.browser == "chrome": - request.applymarker(pytest.mark.xfail(run=False, reason="chrome not supported")) selenium.load_package("scikit-learn") assert ( selenium.run( diff --git a/packages/scipy/test_scipy.py b/packages/scipy/test_scipy.py index 753e55c71..8e636a569 100644 --- a/packages/scipy/test_scipy.py +++ b/packages/scipy/test_scipy.py @@ -6,9 +6,6 @@ import pytest def test_scipy_linalg(selenium_standalone, request): selenium = selenium_standalone - if selenium.browser == "chrome": - request.applymarker(pytest.mark.xfail(run=False, reason="chrome not supported")) - selenium.load_package("scipy") cmd = dedent( r""" diff --git a/packages/test_common.py b/packages/test_common.py index 2abdeb359..3bb77819d 100644 --- a/packages/test_common.py +++ b/packages/test_common.py @@ -26,7 +26,7 @@ def registered_packages_meta(): } -UNSUPPORTED_PACKAGES = {"chrome": ["pandas", "scipy", "scikit-learn"], "firefox": []} +UNSUPPORTED_PACKAGES = {"chrome": [], "firefox": []} @pytest.mark.parametrize("name", registered_packages()) @@ -68,34 +68,9 @@ def test_import(name, selenium_standalone): )) """ ) - - selenium_standalone.load_package(name) - - # Make sure there are no additional .pyc file - assert ( - selenium_standalone.run( - """ - len(list(glob.glob( - '/lib/python3.8/site-packages/**/*.pyc', - recursive=True) - )) - """ - ) - == baseline_pyc - ) - loaded_packages = [] for import_name in meta.get("test", {}).get("imports", []): - - if name not in loaded_packages: - selenium_standalone.load_package(name) - loaded_packages.append(name) - try: - selenium_standalone.run("import %s" % import_name) - except Exception: - print(selenium_standalone.logs) - raise - + selenium_standalone.run_async("import %s" % import_name) # Make sure that even after importing, there are no additional .pyc # files assert (