python-pandas/tests-wasm.patch

139 lines
4.1 KiB
Diff
Raw Normal View History

From 4f743f98649ce1fc17a57f7b02d81f7cc172dff6 Mon Sep 17 00:00:00 2001
From: Agriya Khetarpal <74401230+agriyakhetarpal@users.noreply.github.com>
Date: Wed, 8 May 2024 22:21:57 +0530
Subject: [PATCH] BLD, TST: Build and test Pyodide wheels for `pandas` in CI
(#57896)
* Create initial Pyodide workflow
* Do not import pandas folder from the repo
* Install hypothesis for testing
* Add pytest decorator to skip tests on WASM
* Skip `time.tzset()` tests on WASM platforms
* Skip file system access tests on WASM
* Skip two more tzset test failures
* Skip two more FS failures on WASM
* Resolve last two tzset failures on WASM
* Add a `WASM` constant for Emscripten platform checks
* Fix floating point imprecision with `np.timedelta64`
* Mark tz OverflowError as xfail on WASM
* Try to fix OverflowError with date ranges
* Move job to unit tests workflow, withdraw env vars
* Fix up a few style errors, use WASM variable
* Bump Pyodide to `0.25.1`
See https://github.com/pyodide/pyodide/pull/4654 for
more discussion. This commit resolves a build error
coming from the `pyodide build` command which
broke due to a new `build` release by PyPA.
* Use shorter job name
* Skip test where warning is not raised properly
* Don't run `test_date_time` loc check on WASM
* Don't run additional loc checks in `test_sas7bdat`
* Disable WASM OverflowError
* Skip tests requiring fp exception support
* xfail tests that require stricter tolerances
* xfail test where `OverflowError`s are received
* Remove upper-pin from `pydantic`
* Better skip messages via `pytest.skipif` decorator
* Import `WASM` var via public API where possible
* Unpin `pytest` for Pyodide job
* Add reason attr when using boolean to skip test
* Don't xfail, skip tests that bring `OverflowError`s
* Skip timedelta test that runs well only on 64-bit
* Skip tests that use `np.timedelta64`
---------
Co-authored-by: Matthew Roeschke <10647082+mroeschke@users.noreply.github.com>
---
.github/workflows/unit-tests.yml | 61 ++++++++++++++++++-
pandas/compat/__init__.py | 2 +
pandas/compat/_constants.py | 2 +
pandas/tests/apply/test_str.py | 3 +
pandas/tests/arithmetic/test_timedelta64.py | 2 +
.../datetimes/methods/test_normalize.py | 4 ++
.../datetimes/methods/test_resolution.py | 8 ++-
.../io/parser/common/test_file_buffer_url.py | 3 +
pandas/tests/io/parser/test_c_parser_only.py | 21 ++++---
pandas/tests/io/sas/test_sas7bdat.py | 9 ++-
pandas/tests/io/test_common.py | 10 ++-
pandas/tests/io/xml/test_xml.py | 2 +
.../scalar/timestamp/methods/test_replace.py | 3 +
.../methods/test_timestamp_method.py | 3 +
pandas/tests/scalar/timestamp/test_formats.py | 3 +
pandas/tests/tools/test_to_datetime.py | 6 +-
pandas/tests/tools/test_to_timedelta.py | 6 +-
pandas/tests/tseries/offsets/test_common.py | 8 ++-
pandas/tests/tslibs/test_parsing.py | 2 +
pandas/util/_test_decorators.py | 5 ++
20 files changed, 146 insertions(+), 17 deletions(-)
diff --git a/pandas/compat/__init__.py b/pandas/compat/__init__.py
index 572dd8c9b61a0..4583e7edebbdc 100644
--- a/pandas/compat/__init__.py
+++ b/pandas/compat/__init__.py
@@ -22,6 +22,7 @@
PY311,
PY312,
PYPY,
+ WASM,
)
import pandas.compat.compressors
from pandas.compat.numpy import is_numpy_dev
@@ -207,4 +208,5 @@ def get_bz2_file() -> type[pandas.compat.compressors.BZ2File]:
"PY311",
"PY312",
"PYPY",
+ "WASM",
]
diff --git a/pandas/compat/_constants.py b/pandas/compat/_constants.py
index 7bc3fbaaefebf..2625389e5254a 100644
--- a/pandas/compat/_constants.py
+++ b/pandas/compat/_constants.py
@@ -17,6 +17,7 @@
PY311 = sys.version_info >= (3, 11)
PY312 = sys.version_info >= (3, 12)
PYPY = platform.python_implementation() == "PyPy"
+WASM = (sys.platform == "emscripten") or (platform.machine() in ["wasm32", "wasm64"])
ISMUSL = "musl" in (sysconfig.get_config_var("HOST_GNU_TYPE") or "")
REF_COUNT = 2 if PY311 else 3
@@ -27,4 +28,5 @@
"PY311",
"PY312",
"PYPY",
+ "WASM",
]