diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index 31ed5096991a6..7eae93a6a27e9 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -173,8 +173,8 @@ jobs: pip install hypothesis>=6.34.2 pytest>=7.0.0 pytest-xdist>=2.2.0 pytest-asyncio>=0.17 cd .. # Not a good idea to test within the src tree python -c "import pandas; print(pandas.__version__); - pandas.test(extra_args=['-m not clipboard and not single_cpu and not slow and not network and not db', '-n 2']); - pandas.test(extra_args=['-m not clipboard and single_cpu and not slow and not network and not db'])" + pandas.test(extra_args=['-m not clipboard and not single_cpu and not slow and not network and not db', '-n 2', '--no-strict-data-files']); + pandas.test(extra_args=['-m not clipboard and single_cpu and not slow and not network and not db', '--no-strict-data-files'])" - uses: actions/upload-artifact@v3 with: name: sdist diff --git a/ci/test_wheels.py b/ci/test_wheels.py index f861c1cbedcad..d6f843d7b2c68 100644 --- a/ci/test_wheels.py +++ b/ci/test_wheels.py @@ -41,10 +41,12 @@ multi_args = [ "-m not clipboard and not single_cpu and not slow and not network and not db", "-n 2", + "--no-strict-data-files", ] pd.test(extra_args=multi_args) pd.test( extra_args=[ "-m not clipboard and single_cpu and not slow and not network and not db", + "--no-strict-data-files", ] ) diff --git a/ci/test_wheels_windows.bat b/ci/test_wheels_windows.bat index 33de4fc5ad62d..7a7254c94ccef 100644 --- a/ci/test_wheels_windows.bat +++ b/ci/test_wheels_windows.bat @@ -1,6 +1,6 @@ set test_command=import pandas as pd; print(pd.__version__); ^ -pd.test(extra_args=['-m not clipboard and not single_cpu and not slow and not network and not db', '-n 2']); ^ -pd.test(extra_args=['-m not clipboard and single_cpu and not slow and not network and not db']) +pd.test(extra_args=['-m not clipboard and not single_cpu and not slow and not network and not db', '--no-strict-data-files', '-n=2']); ^ +pd.test(extra_args=['-m not clipboard and single_cpu and not slow and not network and not db', '--no-strict-data-files']) python --version pip install pytz six numpy python-dateutil diff --git a/pandas/conftest.py b/pandas/conftest.py index aab6de1724677..ce15bcfae771d 100644 --- a/pandas/conftest.py +++ b/pandas/conftest.py @@ -103,9 +103,9 @@ def pytest_addoption(parser) -> None: parser.addoption( - "--strict-data-files", - action="store_true", - help="Fail if a test is skipped for missing data file.", + "--no-strict-data-files", + action="store_false", + help="Don't fail if a test is skipped for missing data file.", ) @@ -1110,9 +1110,9 @@ def all_numeric_accumulations(request): @pytest.fixture def strict_data_files(pytestconfig): """ - Returns the configuration for the test setting `--strict-data-files`. + Returns the configuration for the test setting `--no-strict-data-files`. """ - return pytestconfig.getoption("--strict-data-files") + return pytestconfig.getoption("--no-strict-data-files") @pytest.fixture @@ -1132,7 +1132,7 @@ def datapath(strict_data_files: str) -> Callable[..., str]: Raises ------ ValueError - If the path doesn't exist and the --strict-data-files option is set. + If the path doesn't exist and the --no-strict-data-files option is not set. """ BASE_PATH = os.path.join(os.path.dirname(__file__), "tests") @@ -1141,7 +1141,7 @@ def deco(*args): if not os.path.exists(path): if strict_data_files: raise ValueError( - f"Could not find file {path} and --strict-data-files is set." + f"Could not find file {path} and --no-strict-data-files is not set." ) pytest.skip(f"Could not find {path}.") return path diff --git a/pandas/tests/frame/indexing/test_setitem.py b/pandas/tests/frame/indexing/test_setitem.py index c20db86904d06..0455a20923087 100644 --- a/pandas/tests/frame/indexing/test_setitem.py +++ b/pandas/tests/frame/indexing/test_setitem.py @@ -61,7 +61,8 @@ class mystring(str): "dtype", ["int32", "int64", "uint32", "uint64", "float32", "float64"] ) def test_setitem_dtype(self, dtype, float_frame): - arr = np.random.randn(len(float_frame)) + # Use randint since casting negative floats to uints is undefined + arr = np.random.randint(1, 10, len(float_frame)) float_frame[dtype] = np.array(arr, dtype=dtype) assert float_frame[dtype].dtype.name == dtype diff --git a/pandas/tests/series/methods/test_nlargest.py b/pandas/tests/series/methods/test_nlargest.py index 146ba2c42e0be..ecc5d3060c0a2 100644 --- a/pandas/tests/series/methods/test_nlargest.py +++ b/pandas/tests/series/methods/test_nlargest.py @@ -217,7 +217,12 @@ def test_nlargest_boolean(self, data, expected): def test_nlargest_nullable(self, any_numeric_ea_dtype): # GH#42816 dtype = any_numeric_ea_dtype - arr = np.random.randn(10).astype(dtype.lower(), copy=False) + if dtype.startswith("UInt"): + # Can't cast from negative float to uint on some platforms + arr = np.random.randint(1, 10, 10) + else: + arr = np.random.randn(10) + arr = arr.astype(dtype.lower(), copy=False) ser = Series(arr.copy(), dtype=dtype) ser[1] = pd.NA diff --git a/pandas/tests/test_common.py b/pandas/tests/test_common.py index d31f617b9be15..15fa10b9e4289 100644 --- a/pandas/tests/test_common.py +++ b/pandas/tests/test_common.py @@ -1,5 +1,6 @@ import collections from functools import partial +import os import string import numpy as np @@ -174,6 +175,12 @@ def test_version_tag(): ) +def test_pyproject_present(): + # Check pyproject.toml is present(relevant for wheels) + pyproject_loc = os.path.join(os.path.dirname(__file__), "../../pyproject.toml") + assert os.path.exists(pyproject_loc) + + @pytest.mark.parametrize( "obj", [(obj,) for obj in pd.__dict__.values() if callable(obj)] ) diff --git a/pyproject.toml b/pyproject.toml index c3a7cb013ca6c..2162ac59bb7a5 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -126,6 +126,9 @@ include-package-data = true include = ["pandas", "pandas.*"] namespaces = false +[tool.setuptools.package-data] +pandas = ["../pyproject.toml"] + [tool.setuptools.exclude-package-data] "*" = ["*.c", "*.h"] @@ -388,7 +391,7 @@ disable = [ [tool.pytest.ini_options] # sync minversion with pyproject.toml & install.rst minversion = "7.0" -addopts = "--strict-data-files --strict-markers --strict-config --capture=no --durations=30 --junitxml=test-data.xml" +addopts = "--strict-markers --strict-config --capture=no --durations=30 --junitxml=test-data.xml" empty_parameter_set_mark = "fail_at_collect" xfail_strict = true testpaths = "pandas" @@ -398,6 +401,7 @@ doctest_optionflags = [ "ELLIPSIS", ] filterwarnings = [ + "error::_pytest.warning_types.PytestUnknownMarkWarning", "error:::pandas", "error::ResourceWarning", "error::pytest.PytestUnraisableExceptionWarning",