diff --git a/crates/polars-python/src/functions/lazy.rs b/crates/polars-python/src/functions/lazy.rs index c0f9d0f7152aa..eff238b13e1a8 100644 --- a/crates/polars-python/src/functions/lazy.rs +++ b/crates/polars-python/src/functions/lazy.rs @@ -442,12 +442,24 @@ pub fn lit(value: &Bound<'_, PyAny>, allow_object: bool) -> PyResult { }); Ok(dsl::lit(s).into()) } else { - Err(PyTypeError::new_err(format!( - "cannot create expression literal for value of type {}: {}\ - \n\nHint: Pass `allow_object=True` to accept any value and create a literal of type Object.", - value.get_type().qualname()?, - value.repr()? - ))) + Python::with_gil(|py| { + // One final attempt before erroring. Do we have a date/datetime subclass? + // E.g. pd.Timestamp, or Freezegun. + let datetime_module = PyModule::import_bound(py, "datetime")?; + let datetime_class = datetime_module.getattr("datetime")?; + let date_class = datetime_module.getattr("date")?; + if value.is_instance(&datetime_class)? || value.is_instance(&date_class)? { + let av = py_object_to_any_value(value, true)?; + Ok(Expr::Literal(LiteralValue::try_from(av).unwrap()).into()) + } else { + Err(PyTypeError::new_err(format!( + "cannot create expression literal for value of type {}: {}\ + \n\nHint: Pass `allow_object=True` to accept any value and create a literal of type Object.", + value.get_type().name()?, + value.repr()? + ))) + } + }) } } diff --git a/py-polars/tests/benchmark/interop/test_numpy.py b/py-polars/tests/benchmark/interop/test_numpy.py index 5b516b0ecb191..e44b401345588 100644 --- a/py-polars/tests/benchmark/interop/test_numpy.py +++ b/py-polars/tests/benchmark/interop/test_numpy.py @@ -18,19 +18,19 @@ def floats_array() -> np.ndarray[Any, Any]: return np.random.randn(n_rows) -@pytest.fixture +@pytest.fixture() def floats(floats_array: np.ndarray[Any, Any]) -> pl.Series: return pl.Series(floats_array) -@pytest.fixture +@pytest.fixture() def floats_with_nulls(floats: pl.Series) -> pl.Series: null_probability = 0.1 validity = pl.Series(np.random.uniform(size=floats.len())) > null_probability return pl.select(pl.when(validity).then(floats)).to_series() -@pytest.fixture +@pytest.fixture() def floats_chunked(floats_array: np.ndarray[Any, Any]) -> pl.Series: n_chunks = 5 chunk_len = len(floats_array) // n_chunks diff --git a/py-polars/tests/docs/test_user_guide.py b/py-polars/tests/docs/test_user_guide.py index 89203b4d09ebc..08be6fe9dfbfe 100644 --- a/py-polars/tests/docs/test_user_guide.py +++ b/py-polars/tests/docs/test_user_guide.py @@ -29,7 +29,7 @@ def _change_test_dir() -> Iterator[None]: os.chdir(current_path) -@pytest.mark.docs +@pytest.mark.docs() @pytest.mark.parametrize("path", snippet_paths) @pytest.mark.usefixtures("_change_test_dir") def test_run_python_snippets(path: Path) -> None: diff --git a/py-polars/tests/unit/cloud/test_prepare_cloud_plan.py b/py-polars/tests/unit/cloud/test_prepare_cloud_plan.py index a49a0d65e701d..c54d0c7fc7adc 100644 --- a/py-polars/tests/unit/cloud/test_prepare_cloud_plan.py +++ b/py-polars/tests/unit/cloud/test_prepare_cloud_plan.py @@ -94,7 +94,7 @@ def test_prepare_cloud_plan_fail_on_local_data_source(lf: pl.LazyFrame) -> None: prepare_cloud_plan(lf) -@pytest.mark.write_disk +@pytest.mark.write_disk() def test_prepare_cloud_plan_fail_on_python_scan(tmp_path: Path) -> None: tmp_path.mkdir(exist_ok=True) data_path = tmp_path / "data.parquet" diff --git a/py-polars/tests/unit/conftest.py b/py-polars/tests/unit/conftest.py index 7335f8f468350..828ad87684cbe 100644 --- a/py-polars/tests/unit/conftest.py +++ b/py-polars/tests/unit/conftest.py @@ -32,13 +32,13 @@ NESTED_DTYPES = [pl.List, pl.Struct, pl.Array] -@pytest.fixture +@pytest.fixture() def partition_limit() -> int: """The limit at which Polars will start partitioning in debug builds.""" return 15 -@pytest.fixture +@pytest.fixture() def df() -> pl.DataFrame: df = pl.DataFrame( { @@ -68,14 +68,14 @@ def df() -> pl.DataFrame: ) -@pytest.fixture +@pytest.fixture() def df_no_lists(df: pl.DataFrame) -> pl.DataFrame: return df.select( pl.all().exclude(["list_str", "list_int", "list_bool", "list_int", "list_flt"]) ) -@pytest.fixture +@pytest.fixture() def fruits_cars() -> pl.DataFrame: return pl.DataFrame( { @@ -88,7 +88,7 @@ def fruits_cars() -> pl.DataFrame: ) -@pytest.fixture +@pytest.fixture() def str_ints_df() -> pl.DataFrame: n = 1000 @@ -199,7 +199,7 @@ def get_peak(self) -> int: return tracemalloc.get_traced_memory()[1] -@pytest.fixture +@pytest.fixture() def memory_usage_without_pyarrow() -> Generator[MemoryUsage, Any, Any]: """ Provide an API for measuring peak memory usage. diff --git a/py-polars/tests/unit/dataframe/test_df.py b/py-polars/tests/unit/dataframe/test_df.py index 9734cf193a778..fe0b0fb04f828 100644 --- a/py-polars/tests/unit/dataframe/test_df.py +++ b/py-polars/tests/unit/dataframe/test_df.py @@ -1555,7 +1555,7 @@ def test_reproducible_hash_with_seeds() -> None: assert_series_equal(expected, result, check_names=False, check_exact=True) -@pytest.mark.slow +@pytest.mark.slow() @pytest.mark.parametrize( "e", [ diff --git a/py-polars/tests/unit/dataframe/test_from_dict.py b/py-polars/tests/unit/dataframe/test_from_dict.py index 2b87e970d5cb1..effdc47a4d4d8 100644 --- a/py-polars/tests/unit/dataframe/test_from_dict.py +++ b/py-polars/tests/unit/dataframe/test_from_dict.py @@ -145,7 +145,7 @@ def test_from_dict_with_scalars() -> None: assert df9.rows() == [(0, 2, 0, "x"), (1, 1, 0, "x"), (2, 0, 0, "x")] -@pytest.mark.slow +@pytest.mark.slow() def test_from_dict_with_values_mixed() -> None: # a bit of everything mixed_dtype_data: dict[str, Any] = { diff --git a/py-polars/tests/unit/dataframe/test_partition_by.py b/py-polars/tests/unit/dataframe/test_partition_by.py index c78a7043d4b74..a793e19dccc1f 100644 --- a/py-polars/tests/unit/dataframe/test_partition_by.py +++ b/py-polars/tests/unit/dataframe/test_partition_by.py @@ -6,7 +6,7 @@ import polars.selectors as cs -@pytest.fixture +@pytest.fixture() def df() -> pl.DataFrame: return pl.DataFrame( { @@ -75,7 +75,7 @@ def test_partition_by_as_dict_include_keys_false_maintain_order_false() -> None: df.partition_by(["a"], maintain_order=False, include_key=False, as_dict=True) -@pytest.mark.slow +@pytest.mark.slow() def test_partition_by_as_dict_include_keys_false_large() -> None: # test with both as_dict and include_key=False df = pl.DataFrame( diff --git a/py-polars/tests/unit/dataframe/test_serde.py b/py-polars/tests/unit/dataframe/test_serde.py index 8d960db572ae4..ea17420eb8316 100644 --- a/py-polars/tests/unit/dataframe/test_serde.py +++ b/py-polars/tests/unit/dataframe/test_serde.py @@ -85,7 +85,7 @@ def test_df_serde_to_from_buffer( assert_frame_equal(df, read_df, categorical_as_str=True) -@pytest.mark.write_disk +@pytest.mark.write_disk() def test_df_serde_to_from_file(df: pl.DataFrame, tmp_path: Path) -> None: tmp_path.mkdir(exist_ok=True) diff --git a/py-polars/tests/unit/dataframe/test_vstack.py b/py-polars/tests/unit/dataframe/test_vstack.py index 8649471f6099d..138808225a1d8 100644 --- a/py-polars/tests/unit/dataframe/test_vstack.py +++ b/py-polars/tests/unit/dataframe/test_vstack.py @@ -5,12 +5,12 @@ from polars.testing import assert_frame_equal -@pytest.fixture +@pytest.fixture() def df1() -> pl.DataFrame: return pl.DataFrame({"foo": [1, 2], "bar": [6, 7], "ham": ["a", "b"]}) -@pytest.fixture +@pytest.fixture() def df2() -> pl.DataFrame: return pl.DataFrame({"foo": [3, 4], "bar": [8, 9], "ham": ["c", "d"]}) diff --git a/py-polars/tests/unit/datatypes/test_array.py b/py-polars/tests/unit/datatypes/test_array.py index 38e5e5c154fe2..0ded3ee282f6f 100644 --- a/py-polars/tests/unit/datatypes/test_array.py +++ b/py-polars/tests/unit/datatypes/test_array.py @@ -176,7 +176,7 @@ def test_cast_list_to_array(data: Any, inner_type: pl.DataType) -> None: assert s.to_list() == data -@pytest.fixture +@pytest.fixture() def data_dispersion() -> pl.DataFrame: return pl.DataFrame( { diff --git a/py-polars/tests/unit/datatypes/test_bool.py b/py-polars/tests/unit/datatypes/test_bool.py index 981167838e56d..34a4b0d589a63 100644 --- a/py-polars/tests/unit/datatypes/test_bool.py +++ b/py-polars/tests/unit/datatypes/test_bool.py @@ -6,7 +6,7 @@ import polars as pl -@pytest.mark.slow +@pytest.mark.slow() def test_bool_arg_min_max() -> None: # masks that ensures we take more than u64 chunks # and slicing and dicing to ensure the offsets work diff --git a/py-polars/tests/unit/datatypes/test_categorical.py b/py-polars/tests/unit/datatypes/test_categorical.py index b898c7c079997..bd9f0524824d0 100644 --- a/py-polars/tests/unit/datatypes/test_categorical.py +++ b/py-polars/tests/unit/datatypes/test_categorical.py @@ -480,7 +480,7 @@ def test_cast_inner_categorical() -> None: ) -@pytest.mark.slow +@pytest.mark.slow() def test_stringcache() -> None: N = 1_500 with pl.StringCache(): diff --git a/py-polars/tests/unit/datatypes/test_decimal.py b/py-polars/tests/unit/datatypes/test_decimal.py index dd61f150ef75d..64b0d5fe5068f 100644 --- a/py-polars/tests/unit/datatypes/test_decimal.py +++ b/py-polars/tests/unit/datatypes/test_decimal.py @@ -29,7 +29,7 @@ def permutations_int_dec_none() -> list[tuple[D | int | None, ...]]: ) -@pytest.mark.slow +@pytest.mark.slow() def test_series_from_pydecimal_and_ints( permutations_int_dec_none: list[tuple[D | int | None, ...]], ) -> None: @@ -45,7 +45,7 @@ def test_series_from_pydecimal_and_ints( assert s.to_list() == [D(x) if x is not None else None for x in data] -@pytest.mark.slow +@pytest.mark.slow() def test_frame_from_pydecimal_and_ints( permutations_int_dec_none: list[tuple[D | int | None, ...]], monkeypatch: Any ) -> None: diff --git a/py-polars/tests/unit/datatypes/test_list.py b/py-polars/tests/unit/datatypes/test_list.py index 4607cfa894260..173502c30a97e 100644 --- a/py-polars/tests/unit/datatypes/test_list.py +++ b/py-polars/tests/unit/datatypes/test_list.py @@ -667,7 +667,7 @@ def test_as_list_logical_type() -> None: ).to_dict(as_series=False) == {"literal": [True], "timestamp": [[date(2000, 1, 1)]]} -@pytest.fixture +@pytest.fixture() def data_dispersion() -> pl.DataFrame: return pl.DataFrame( { diff --git a/py-polars/tests/unit/functions/range/test_date_range.py b/py-polars/tests/unit/functions/range/test_date_range.py index 0c15adae778a1..a881d30c1e41c 100644 --- a/py-polars/tests/unit/functions/range/test_date_range.py +++ b/py-polars/tests/unit/functions/range/test_date_range.py @@ -310,3 +310,17 @@ def test_date_ranges_datetime_input() -> None: "literal", [[date(2022, 1, 1), date(2022, 1, 2), date(2022, 1, 3)]] ) assert_series_equal(result, expected) + + +def test_date_range_with_subclass_18470_18447() -> None: + class MyAmazingDate(date): + pass + + class MyAmazingDatetime(datetime): + pass + + result = pl.datetime_range( + MyAmazingDate(2020, 1, 1), MyAmazingDatetime(2020, 1, 2), eager=True + ) + expected = pl.Series("literal", [datetime(2020, 1, 1), datetime(2020, 1, 2)]) + assert_series_equal(result, expected) diff --git a/py-polars/tests/unit/functions/test_concat.py b/py-polars/tests/unit/functions/test_concat.py index e73c7fc9997fb..8e7c4c9f31e34 100644 --- a/py-polars/tests/unit/functions/test_concat.py +++ b/py-polars/tests/unit/functions/test_concat.py @@ -3,7 +3,7 @@ import polars as pl -@pytest.mark.slow +@pytest.mark.slow() def test_concat_expressions_stack_overflow() -> None: n = 10000 e = pl.concat([pl.lit(x) for x in range(n)]) @@ -12,7 +12,7 @@ def test_concat_expressions_stack_overflow() -> None: assert df.shape == (n, 1) -@pytest.mark.slow +@pytest.mark.slow() def test_concat_lf_stack_overflow() -> None: n = 1000 bar = pl.DataFrame({"a": 0}).lazy() diff --git a/py-polars/tests/unit/functions/test_when_then.py b/py-polars/tests/unit/functions/test_when_then.py index 6f70b9c1b9d1c..0690782bbad97 100644 --- a/py-polars/tests/unit/functions/test_when_then.py +++ b/py-polars/tests/unit/functions/test_when_then.py @@ -529,7 +529,7 @@ def test_when_then_null_broadcast() -> None: ) -@pytest.mark.slow +@pytest.mark.slow() @pytest.mark.parametrize("len", [1, 10, 100, 500]) @pytest.mark.parametrize( ("dtype", "vals"), diff --git a/py-polars/tests/unit/interchange/test_from_dataframe.py b/py-polars/tests/unit/interchange/test_from_dataframe.py index 35fcc595451ac..62f34666f8b1c 100644 --- a/py-polars/tests/unit/interchange/test_from_dataframe.py +++ b/py-polars/tests/unit/interchange/test_from_dataframe.py @@ -406,13 +406,13 @@ def test_construct_offsets_buffer_copy() -> None: assert_series_equal(result, expected) -@pytest.fixture +@pytest.fixture() def bitmask() -> PolarsBuffer: data = pl.Series([False, True, True, False]) return PolarsBuffer(data) -@pytest.fixture +@pytest.fixture() def bytemask() -> PolarsBuffer: data = pl.Series([0, 1, 1, 0], dtype=pl.UInt8) return PolarsBuffer(data) diff --git a/py-polars/tests/unit/interop/test_from_pandas.py b/py-polars/tests/unit/interop/test_from_pandas.py index c22d8abafd219..97df7986e296c 100644 --- a/py-polars/tests/unit/interop/test_from_pandas.py +++ b/py-polars/tests/unit/interop/test_from_pandas.py @@ -321,7 +321,7 @@ def test_untrusted_categorical_input() -> None: assert_frame_equal(result, expected, categorical_as_str=True) -@pytest.fixture +@pytest.fixture() def _set_pyarrow_unavailable(monkeypatch: pytest.MonkeyPatch) -> None: monkeypatch.setattr( "polars._utils.construction.dataframe._PYARROW_AVAILABLE", False diff --git a/py-polars/tests/unit/io/cloud/test_aws.py b/py-polars/tests/unit/io/cloud/test_aws.py index 9a004a7d825f9..3c9f4a159d88b 100644 --- a/py-polars/tests/unit/io/cloud/test_aws.py +++ b/py-polars/tests/unit/io/cloud/test_aws.py @@ -49,7 +49,7 @@ def s3_base(monkeypatch_module: Any) -> Iterator[str]: p.kill() -@pytest.fixture +@pytest.fixture() def s3(s3_base: str, io_files_path: Path) -> str: region = "us-east-1" client = boto3.client("s3", region_name=region, endpoint_url=s3_base) diff --git a/py-polars/tests/unit/io/cloud/test_cloud.py b/py-polars/tests/unit/io/cloud/test_cloud.py index f943ab5e2c266..baf08d2b474ae 100644 --- a/py-polars/tests/unit/io/cloud/test_cloud.py +++ b/py-polars/tests/unit/io/cloud/test_cloud.py @@ -4,7 +4,7 @@ from polars.exceptions import ComputeError -@pytest.mark.slow +@pytest.mark.slow() @pytest.mark.parametrize("format", ["parquet", "csv", "ndjson", "ipc"]) def test_scan_nonexistent_cloud_path_17444(format: str) -> None: # https://github.com/pola-rs/polars/issues/17444 diff --git a/py-polars/tests/unit/io/conftest.py b/py-polars/tests/unit/io/conftest.py index df245c097be44..fd174486b25ff 100644 --- a/py-polars/tests/unit/io/conftest.py +++ b/py-polars/tests/unit/io/conftest.py @@ -5,6 +5,6 @@ import pytest -@pytest.fixture +@pytest.fixture() def io_files_path() -> Path: return Path(__file__).parent / "files" diff --git a/py-polars/tests/unit/io/database/conftest.py b/py-polars/tests/unit/io/database/conftest.py index 8fcdc27547a30..2ff027329ee02 100644 --- a/py-polars/tests/unit/io/database/conftest.py +++ b/py-polars/tests/unit/io/database/conftest.py @@ -10,7 +10,7 @@ from pathlib import Path -@pytest.fixture +@pytest.fixture() def tmp_sqlite_db(tmp_path: Path) -> Path: test_db = tmp_path / "test.db" test_db.unlink(missing_ok=True) @@ -51,7 +51,7 @@ def convert_date(val: bytes) -> date: return test_db -@pytest.fixture +@pytest.fixture() def tmp_sqlite_inference_db(tmp_path: Path) -> Path: test_db = tmp_path / "test_inference.db" test_db.unlink(missing_ok=True) diff --git a/py-polars/tests/unit/io/database/test_read.py b/py-polars/tests/unit/io/database/test_read.py index 9d9969ece5f53..812107179cd75 100644 --- a/py-polars/tests/unit/io/database/test_read.py +++ b/py-polars/tests/unit/io/database/test_read.py @@ -150,7 +150,7 @@ class ExceptionTestParams(NamedTuple): kwargs: dict[str, Any] | None = None -@pytest.mark.write_disk +@pytest.mark.write_disk() @pytest.mark.parametrize( ( "read_method", @@ -698,7 +698,7 @@ def test_read_database_cx_credentials(uri: str) -> None: pl.read_database_uri("SELECT * FROM data", uri=uri, engine="connectorx") -@pytest.mark.write_disk +@pytest.mark.write_disk() def test_read_kuzu_graph_database(tmp_path: Path, io_files_path: Path) -> None: import kuzu diff --git a/py-polars/tests/unit/io/database/test_write.py b/py-polars/tests/unit/io/database/test_write.py index f734a01850ea0..1a995e31df643 100644 --- a/py-polars/tests/unit/io/database/test_write.py +++ b/py-polars/tests/unit/io/database/test_write.py @@ -18,7 +18,7 @@ from polars._typing import DbWriteEngine -@pytest.mark.write_disk +@pytest.mark.write_disk() @pytest.mark.parametrize( ("engine", "uri_connection"), [ @@ -237,7 +237,7 @@ def test_write_database_errors( df.write_database(connection=True, table_name="misc") # type: ignore[arg-type] -@pytest.mark.write_disk +@pytest.mark.write_disk() def test_write_database_using_sa_session(tmp_path: str) -> None: df = pl.DataFrame( { @@ -261,7 +261,7 @@ def test_write_database_using_sa_session(tmp_path: str) -> None: assert_frame_equal(result, df) -@pytest.mark.write_disk +@pytest.mark.write_disk() @pytest.mark.parametrize("pass_connection", [True, False]) def test_write_database_sa_rollback(tmp_path: str, pass_connection: bool) -> None: df = pl.DataFrame( @@ -291,7 +291,7 @@ def test_write_database_sa_rollback(tmp_path: str, pass_connection: bool) -> Non assert count == 0 -@pytest.mark.write_disk +@pytest.mark.write_disk() @pytest.mark.parametrize("pass_connection", [True, False]) def test_write_database_sa_commit(tmp_path: str, pass_connection: bool) -> None: df = pl.DataFrame( diff --git a/py-polars/tests/unit/io/test_avro.py b/py-polars/tests/unit/io/test_avro.py index bfd960a602284..8a622f041c6ed 100644 --- a/py-polars/tests/unit/io/test_avro.py +++ b/py-polars/tests/unit/io/test_avro.py @@ -17,7 +17,7 @@ COMPRESSIONS = ["uncompressed", "snappy", "deflate"] -@pytest.fixture +@pytest.fixture() def example_df() -> pl.DataFrame: return pl.DataFrame({"i64": [1, 2], "f64": [0.1, 0.2], "str": ["a", "b"]}) @@ -32,7 +32,7 @@ def test_from_to_buffer(example_df: pl.DataFrame, compression: AvroCompression) assert_frame_equal(example_df, read_df) -@pytest.mark.write_disk +@pytest.mark.write_disk() @pytest.mark.parametrize("compression", COMPRESSIONS) def test_from_to_file( example_df: pl.DataFrame, compression: AvroCompression, tmp_path: Path diff --git a/py-polars/tests/unit/io/test_csv.py b/py-polars/tests/unit/io/test_csv.py index eab89d3b78554..25bb3076df299 100644 --- a/py-polars/tests/unit/io/test_csv.py +++ b/py-polars/tests/unit/io/test_csv.py @@ -28,7 +28,7 @@ from tests.unit.conftest import MemoryUsage -@pytest.fixture +@pytest.fixture() def foods_file_path(io_files_path: Path) -> Path: return io_files_path / "foods1.csv" @@ -85,7 +85,7 @@ def test_to_from_buffer(df_no_lists: pl.DataFrame) -> None: assert_frame_equal(df.select("time", "cat"), read_df, categorical_as_str=True) -@pytest.mark.write_disk +@pytest.mark.write_disk() def test_to_from_file(df_no_lists: pl.DataFrame, tmp_path: Path) -> None: tmp_path.mkdir(exist_ok=True) @@ -455,7 +455,7 @@ def test_read_csv_buffer_ownership() -> None: assert buf.read() == bts -@pytest.mark.write_disk +@pytest.mark.write_disk() def test_read_csv_encoding(tmp_path: Path) -> None: tmp_path.mkdir(exist_ok=True) @@ -1101,7 +1101,7 @@ def test_csv_string_escaping() -> None: assert_frame_equal(df_read, df) -@pytest.mark.write_disk +@pytest.mark.write_disk() def test_glob_csv(df_no_lists: pl.DataFrame, tmp_path: Path) -> None: tmp_path.mkdir(exist_ok=True) @@ -1639,7 +1639,7 @@ def test_csv_statistics_offset() -> None: assert pl.read_csv(io.StringIO(csv), n_rows=N).height == 4999 -@pytest.mark.write_disk +@pytest.mark.write_disk() def test_csv_scan_categorical(tmp_path: Path) -> None: tmp_path.mkdir(exist_ok=True) @@ -1653,7 +1653,7 @@ def test_csv_scan_categorical(tmp_path: Path) -> None: assert result["x"].dtype == pl.Categorical -@pytest.mark.write_disk +@pytest.mark.write_disk() def test_csv_scan_new_columns_less_than_original_columns(tmp_path: Path) -> None: tmp_path.mkdir(exist_ok=True) @@ -1694,14 +1694,14 @@ def test_read_empty_csv(io_files_path: Path) -> None: assert_frame_equal(df, pl.DataFrame()) -@pytest.mark.slow +@pytest.mark.slow() def test_read_web_file() -> None: url = "https://raw.githubusercontent.com/pola-rs/polars/main/examples/datasets/foods1.csv" df = pl.read_csv(url) assert df.shape == (27, 4) -@pytest.mark.slow +@pytest.mark.slow() def test_csv_multiline_splits() -> None: # create a very unlikely csv file with many multilines in a # single field (e.g. 5000). polars must reject multi-threading here @@ -2008,7 +2008,7 @@ def test_invalid_csv_raise() -> None: ) -@pytest.mark.write_disk +@pytest.mark.write_disk() def test_partial_read_compressed_file( tmp_path: Path, monkeypatch: pytest.MonkeyPatch ) -> None: @@ -2066,8 +2066,8 @@ def test_csv_invalid_escape_utf8_14960() -> None: pl.read_csv('col1\n""•'.encode()) -@pytest.mark.slow -@pytest.mark.write_disk +@pytest.mark.slow() +@pytest.mark.write_disk() def test_read_csv_only_loads_selected_columns( memory_usage_without_pyarrow: MemoryUsage, tmp_path: Path, @@ -2133,7 +2133,7 @@ def test_csv_escape_cf_15349() -> None: assert f.read() == b'test\nnormal\n"with\rcr"\n' -@pytest.mark.write_disk +@pytest.mark.write_disk() @pytest.mark.parametrize("streaming", [True, False]) def test_skip_rows_after_header(tmp_path: Path, streaming: bool) -> None: tmp_path.mkdir(exist_ok=True) @@ -2233,7 +2233,7 @@ def test_projection_applied_on_file_with_no_rows_16606(tmp_path: Path) -> None: assert out == columns -@pytest.mark.write_disk +@pytest.mark.write_disk() def test_write_csv_to_dangling_file_17328( df_no_lists: pl.DataFrame, tmp_path: Path ) -> None: @@ -2249,7 +2249,7 @@ def test_write_csv_raise_on_non_utf8_17328( df_no_lists.write_csv((tmp_path / "dangling.csv").open("w", encoding="gbk")) -@pytest.mark.write_disk +@pytest.mark.write_disk() def test_write_csv_appending_17543(tmp_path: Path) -> None: tmp_path.mkdir(exist_ok=True) df = pl.DataFrame({"col": ["value"]}) diff --git a/py-polars/tests/unit/io/test_delta.py b/py-polars/tests/unit/io/test_delta.py index 6cb487f4abb03..564e900523213 100644 --- a/py-polars/tests/unit/io/test_delta.py +++ b/py-polars/tests/unit/io/test_delta.py @@ -15,7 +15,7 @@ from polars.testing import assert_frame_equal, assert_frame_not_equal -@pytest.fixture +@pytest.fixture() def delta_table_path(io_files_path: Path) -> Path: return io_files_path / "delta-table" @@ -34,7 +34,7 @@ def test_scan_delta_version(delta_table_path: Path) -> None: assert_frame_not_equal(df1, df2) -@pytest.mark.write_disk +@pytest.mark.write_disk() def test_scan_delta_timestamp_version(tmp_path: Path) -> None: df_sample = pl.DataFrame({"name": ["Joey"], "age": [14]}) df_sample.write_delta(tmp_path, mode="append") @@ -107,7 +107,7 @@ def test_read_delta_version(delta_table_path: Path) -> None: assert_frame_not_equal(df1, df2) -@pytest.mark.write_disk +@pytest.mark.write_disk() def test_read_delta_timestamp_version(tmp_path: Path) -> None: df_sample = pl.DataFrame({"name": ["Joey"], "age": [14]}) df_sample.write_delta(tmp_path, mode="append") @@ -163,7 +163,7 @@ def test_read_delta_relative(delta_table_path: Path) -> None: assert_frame_equal(expected, df, check_dtypes=False) -@pytest.mark.write_disk +@pytest.mark.write_disk() def test_write_delta(df: pl.DataFrame, tmp_path: Path) -> None: v0 = df.select(pl.col(pl.String)) v1 = df.select(pl.col(pl.Int64)) @@ -245,7 +245,7 @@ def test_write_delta(df: pl.DataFrame, tmp_path: Path) -> None: df_supported.write_delta(partitioned_tbl_uri, mode="overwrite") -@pytest.mark.write_disk +@pytest.mark.write_disk() def test_write_delta_overwrite_schema_deprecated( df: pl.DataFrame, tmp_path: Path ) -> None: @@ -256,7 +256,7 @@ def test_write_delta_overwrite_schema_deprecated( assert_frame_equal(df, result) -@pytest.mark.write_disk +@pytest.mark.write_disk() @pytest.mark.parametrize( "series", [ @@ -410,7 +410,7 @@ def test_write_delta_w_compatible_schema(series: pl.Series, tmp_path: Path) -> N assert tbl.version() == 1 -@pytest.mark.write_disk +@pytest.mark.write_disk() def test_write_delta_with_schema_10540(tmp_path: Path) -> None: df = pl.DataFrame({"a": [1, 2, 3]}) @@ -418,7 +418,7 @@ def test_write_delta_with_schema_10540(tmp_path: Path) -> None: df.write_delta(tmp_path, delta_write_options={"schema": pa_schema}) -@pytest.mark.write_disk +@pytest.mark.write_disk() @pytest.mark.parametrize( "expr", [ @@ -455,7 +455,7 @@ def test_write_delta_with_merge_and_no_table(tmp_path: Path) -> None: ) -@pytest.mark.write_disk +@pytest.mark.write_disk() def test_write_delta_with_merge(tmp_path: Path) -> None: df = pl.DataFrame({"a": [1, 2, 3]}) @@ -484,7 +484,7 @@ def test_write_delta_with_merge(tmp_path: Path) -> None: assert_frame_equal(result, expected, check_row_order=False) -@pytest.mark.write_disk +@pytest.mark.write_disk() def test_unsupported_dtypes(tmp_path: Path) -> None: df = pl.DataFrame({"a": [None]}, schema={"a": pl.Null}) with pytest.raises(TypeError, match="unsupported data type"): @@ -495,7 +495,7 @@ def test_unsupported_dtypes(tmp_path: Path) -> None: df.write_delta(tmp_path / "time") -@pytest.mark.write_disk +@pytest.mark.write_disk() def test_categorical_becomes_string(tmp_path: Path) -> None: df = pl.DataFrame({"a": ["A", "B", "A"]}, schema={"a": pl.Categorical}) df.write_delta(tmp_path) @@ -503,7 +503,7 @@ def test_categorical_becomes_string(tmp_path: Path) -> None: assert_frame_equal(df2, pl.DataFrame({"a": ["A", "B", "A"]}, schema={"a": pl.Utf8})) -@pytest.mark.write_disk +@pytest.mark.write_disk() @pytest.mark.parametrize("rechunk_and_expected_chunks", [(True, 1), (False, 3)]) def test_read_parquet_respects_rechunk_16982( rechunk_and_expected_chunks: tuple[bool, int], tmp_path: Path diff --git a/py-polars/tests/unit/io/test_hive.py b/py-polars/tests/unit/io/test_hive.py index ad285b82f3b3b..c677b24e6e07b 100644 --- a/py-polars/tests/unit/io/test_hive.py +++ b/py-polars/tests/unit/io/test_hive.py @@ -71,7 +71,7 @@ def impl_test_hive_partitioned_predicate_pushdown( @pytest.mark.xdist_group("streaming") -@pytest.mark.write_disk +@pytest.mark.write_disk() def test_hive_partitioned_predicate_pushdown( io_files_path: Path, tmp_path: Path, @@ -87,7 +87,7 @@ def test_hive_partitioned_predicate_pushdown( @pytest.mark.xdist_group("streaming") -@pytest.mark.write_disk +@pytest.mark.write_disk() def test_hive_partitioned_predicate_pushdown_single_threaded_async_17155( io_files_path: Path, tmp_path: Path, @@ -105,7 +105,7 @@ def test_hive_partitioned_predicate_pushdown_single_threaded_async_17155( ) -@pytest.mark.write_disk +@pytest.mark.write_disk() def test_hive_partitioned_predicate_pushdown_skips_correct_number_of_files( io_files_path: Path, tmp_path: Path, monkeypatch: Any, capfd: Any ) -> None: @@ -136,7 +136,7 @@ def test_hive_partitioned_predicate_pushdown_skips_correct_number_of_files( @pytest.mark.xdist_group("streaming") -@pytest.mark.write_disk +@pytest.mark.write_disk() @pytest.mark.parametrize("streaming", [True, False]) def test_hive_partitioned_slice_pushdown( io_files_path: Path, tmp_path: Path, streaming: bool @@ -170,7 +170,7 @@ def test_hive_partitioned_slice_pushdown( @pytest.mark.xdist_group("streaming") -@pytest.mark.write_disk +@pytest.mark.write_disk() def test_hive_partitioned_projection_pushdown( io_files_path: Path, tmp_path: Path ) -> None: @@ -207,7 +207,7 @@ def test_hive_partitioned_projection_pushdown( assert_frame_equal(result, expected) -@pytest.mark.write_disk +@pytest.mark.write_disk() def test_hive_partitioned_projection_skip_files( io_files_path: Path, tmp_path: Path ) -> None: @@ -232,7 +232,7 @@ def test_hive_partitioned_projection_skip_files( assert_frame_equal(df, test_df) -@pytest.fixture +@pytest.fixture() def dataset_path(tmp_path: Path) -> Path: tmp_path.mkdir(exist_ok=True) @@ -253,7 +253,7 @@ def dataset_path(tmp_path: Path) -> Path: return root -@pytest.mark.write_disk +@pytest.mark.write_disk() def test_scan_parquet_hive_schema(dataset_path: Path) -> None: result = pl.scan_parquet(dataset_path / "**/*.parquet", hive_partitioning=True) assert result.collect_schema() == OrderedDict( @@ -271,7 +271,7 @@ def test_scan_parquet_hive_schema(dataset_path: Path) -> None: assert result.collect().schema == expected_schema -@pytest.mark.write_disk +@pytest.mark.write_disk() def test_read_parquet_invalid_hive_schema(dataset_path: Path) -> None: with pytest.raises( SchemaFieldNotFoundError, @@ -467,7 +467,7 @@ def test_hive_partition_schema_inference(tmp_path: Path) -> None: assert_series_equal(out["a"], expected[i]) -@pytest.mark.write_disk +@pytest.mark.write_disk() def test_hive_partition_force_async_17155(tmp_path: Path, monkeypatch: Any) -> None: monkeypatch.setenv("POLARS_FORCE_ASYNC", "1") monkeypatch.setenv("POLARS_PREFETCH_SIZE", "1") @@ -502,7 +502,7 @@ def test_hive_partition_force_async_17155(tmp_path: Path, monkeypatch: Any) -> N (pl.scan_ipc, pl.DataFrame.write_ipc), ], ) -@pytest.mark.write_disk +@pytest.mark.write_disk() @pytest.mark.parametrize("projection_pushdown", [True, False]) def test_hive_partition_columns_contained_in_file( tmp_path: Path, @@ -555,7 +555,7 @@ def assert_with_projections(lf: pl.LazyFrame, df: pl.DataFrame) -> None: assert_with_projections(lf, rhs) -@pytest.mark.write_disk +@pytest.mark.write_disk() def test_hive_partition_dates(tmp_path: Path) -> None: df = pl.DataFrame( { @@ -631,7 +631,7 @@ def test_hive_partition_dates(tmp_path: Path) -> None: (pl.scan_ipc, pl.DataFrame.write_ipc), ], ) -@pytest.mark.write_disk +@pytest.mark.write_disk() def test_projection_only_hive_parts_gives_correct_number_of_rows( tmp_path: Path, scan_func: Callable[[Any], pl.LazyFrame], @@ -669,7 +669,7 @@ def test_projection_only_hive_parts_gives_correct_number_of_rows( ), ], ) -@pytest.mark.write_disk +@pytest.mark.write_disk() def test_hive_write(tmp_path: Path, df: pl.DataFrame) -> None: root = tmp_path df.write_parquet(root, partition_by=["a", "b"]) @@ -681,8 +681,8 @@ def test_hive_write(tmp_path: Path, df: pl.DataFrame) -> None: assert_frame_equal(lf.collect(), df.with_columns(pl.col("a", "b").cast(pl.String))) -@pytest.mark.slow -@pytest.mark.write_disk +@pytest.mark.slow() +@pytest.mark.write_disk() def test_hive_write_multiple_files(tmp_path: Path) -> None: chunk_size = 262_144 n_rows = 100_000 @@ -699,7 +699,7 @@ def test_hive_write_multiple_files(tmp_path: Path) -> None: assert_frame_equal(pl.scan_parquet(root).collect(), df) -@pytest.mark.write_disk +@pytest.mark.write_disk() def test_hive_write_dates(tmp_path: Path) -> None: df = pl.DataFrame( { @@ -733,7 +733,7 @@ def test_hive_write_dates(tmp_path: Path) -> None: ) -@pytest.mark.write_disk +@pytest.mark.write_disk() def test_hive_predicate_dates_14712( tmp_path: Path, monkeypatch: Any, capfd: Any ) -> None: diff --git a/py-polars/tests/unit/io/test_iceberg.py b/py-polars/tests/unit/io/test_iceberg.py index 5a5f6769e3a5b..0d80816552f5e 100644 --- a/py-polars/tests/unit/io/test_iceberg.py +++ b/py-polars/tests/unit/io/test_iceberg.py @@ -12,7 +12,7 @@ from polars.io.iceberg import _convert_predicate, _to_ast -@pytest.fixture +@pytest.fixture() def iceberg_path(io_files_path: Path) -> str: # Iceberg requires absolute paths, so we'll symlink # the test table into /tmp/iceberg/t1/ @@ -26,12 +26,12 @@ def iceberg_path(io_files_path: Path) -> str: return f"file://{iceberg_path.resolve()}" -@pytest.mark.slow -@pytest.mark.write_disk +@pytest.mark.slow() +@pytest.mark.write_disk() @pytest.mark.filterwarnings( "ignore:No preferred file implementation for scheme*:UserWarning" ) -@pytest.mark.ci_only +@pytest.mark.ci_only() class TestIcebergScanIO: """Test coverage for `iceberg` scan ops.""" @@ -88,7 +88,7 @@ def test_scan_iceberg_filter_on_column(self, iceberg_path: str) -> None: ] -@pytest.mark.ci_only +@pytest.mark.ci_only() class TestIcebergExpressions: """Test coverage for `iceberg` expressions comprehension.""" diff --git a/py-polars/tests/unit/io/test_ipc.py b/py-polars/tests/unit/io/test_ipc.py index 18e19f4ec8855..1c0b7ed4516cc 100644 --- a/py-polars/tests/unit/io/test_ipc.py +++ b/py-polars/tests/unit/io/test_ipc.py @@ -58,7 +58,7 @@ def test_from_to_buffer( @pytest.mark.parametrize("compression", COMPRESSIONS) @pytest.mark.parametrize("path_as_string", [True, False]) @pytest.mark.parametrize("stream", [True, False]) -@pytest.mark.write_disk +@pytest.mark.write_disk() def test_from_to_file( df: pl.DataFrame, compression: IpcCompression, @@ -77,7 +77,7 @@ def test_from_to_file( @pytest.mark.parametrize("stream", [True, False]) -@pytest.mark.write_disk +@pytest.mark.write_disk() def test_select_columns_from_file( df: pl.DataFrame, tmp_path: Path, stream: bool ) -> None: @@ -153,7 +153,7 @@ def test_ipc_schema(compression: IpcCompression) -> None: assert pl.read_ipc_schema(f) == expected -@pytest.mark.write_disk +@pytest.mark.write_disk() @pytest.mark.parametrize("compression", COMPRESSIONS) @pytest.mark.parametrize("path_as_string", [True, False]) def test_ipc_schema_from_file( @@ -208,7 +208,7 @@ def test_ipc_column_order(stream: bool) -> None: assert read_ipc(stream, f, columns=columns).columns == columns -@pytest.mark.write_disk +@pytest.mark.write_disk() def test_glob_ipc(df: pl.DataFrame, tmp_path: Path) -> None: file_path = tmp_path / "small.ipc" df.write_ipc(file_path) @@ -231,7 +231,7 @@ def test_from_float16() -> None: assert pl.read_ipc(f, use_pyarrow=False).dtypes == [pl.Float32] -@pytest.mark.write_disk +@pytest.mark.write_disk() def test_binview_ipc_mmap(tmp_path: Path) -> None: df = pl.DataFrame({"foo": ["aa" * 10, "bb", None, "small", "big" * 20]}) file_path = tmp_path / "dump.ipc" @@ -262,7 +262,7 @@ def test_struct_nested_enum() -> None: assert df.get_column("struct_cat").dtype == dtype -@pytest.mark.slow +@pytest.mark.slow() def test_ipc_view_gc_14448() -> None: f = io.BytesIO() # This size was required to trigger the bug @@ -274,8 +274,8 @@ def test_ipc_view_gc_14448() -> None: assert_frame_equal(pl.read_ipc(f), df) -@pytest.mark.slow -@pytest.mark.write_disk +@pytest.mark.slow() +@pytest.mark.write_disk() @pytest.mark.parametrize("stream", [True, False]) def test_read_ipc_only_loads_selected_columns( memory_usage_without_pyarrow: MemoryUsage, @@ -313,7 +313,7 @@ def test_read_ipc_only_loads_selected_columns( assert 16_000_000 < memory_usage_without_pyarrow.get_peak() < 23_000_000 -@pytest.mark.write_disk +@pytest.mark.write_disk() def test_ipc_decimal_15920( tmp_path: Path, ) -> None: @@ -341,7 +341,7 @@ def test_ipc_decimal_15920( assert_frame_equal(pl.read_ipc(path), df) -@pytest.mark.write_disk +@pytest.mark.write_disk() def test_ipc_raise_on_writing_mmap(tmp_path: Path) -> None: p = tmp_path / "foo.ipc" df = pl.DataFrame({"foo": [1, 2, 3]}) diff --git a/py-polars/tests/unit/io/test_json.py b/py-polars/tests/unit/io/test_json.py index 4bce4ee4e0cec..f6b9cc3c7a9d2 100644 --- a/py-polars/tests/unit/io/test_json.py +++ b/py-polars/tests/unit/io/test_json.py @@ -306,7 +306,7 @@ def test_ndjson_null_inference_13183() -> None: } -@pytest.mark.write_disk +@pytest.mark.write_disk() @typing.no_type_check def test_json_wrong_input_handle_textio(tmp_path: Path) -> None: # this shouldn't be passed, but still we test if we can handle it gracefully diff --git a/py-polars/tests/unit/io/test_lazy_count_star.py b/py-polars/tests/unit/io/test_lazy_count_star.py index 7b988bed75c79..a20f4ea75a360 100644 --- a/py-polars/tests/unit/io/test_lazy_count_star.py +++ b/py-polars/tests/unit/io/test_lazy_count_star.py @@ -27,7 +27,7 @@ def test_count_csv(io_files_path: Path, path: str, n_rows: int) -> None: assert_frame_equal(lf.collect(), expected) -@pytest.mark.write_disk +@pytest.mark.write_disk() def test_commented_csv() -> None: csv_a = NamedTemporaryFile() csv_a.write( diff --git a/py-polars/tests/unit/io/test_lazy_csv.py b/py-polars/tests/unit/io/test_lazy_csv.py index aee85eb53a0d1..5672c4b1b7c4a 100644 --- a/py-polars/tests/unit/io/test_lazy_csv.py +++ b/py-polars/tests/unit/io/test_lazy_csv.py @@ -12,7 +12,7 @@ from polars.testing import assert_frame_equal -@pytest.fixture +@pytest.fixture() def foods_file_path(io_files_path: Path) -> Path: return io_files_path / "foods1.csv" @@ -36,7 +36,7 @@ def test_scan_empty_csv(io_files_path: Path) -> None: assert_frame_equal(lf, pl.LazyFrame()) -@pytest.mark.write_disk +@pytest.mark.write_disk() def test_invalid_utf8(tmp_path: Path) -> None: tmp_path.mkdir(exist_ok=True) @@ -206,7 +206,7 @@ def test_lazy_row_index_no_push_down(foods_file_path: Path) -> None: assert 'SELECTION: [(col("category")) == (String(vegetables))]' in plan -@pytest.mark.write_disk +@pytest.mark.write_disk() def test_glob_skip_rows(tmp_path: Path) -> None: tmp_path.mkdir(exist_ok=True) @@ -276,7 +276,7 @@ def test_scan_csv_slice_offset_zero(io_files_path: Path) -> None: assert result.collect().height == 4 -@pytest.mark.write_disk +@pytest.mark.write_disk() def test_scan_empty_csv_with_row_index(tmp_path: Path) -> None: tmp_path.mkdir(exist_ok=True) file_path = tmp_path / "small.parquet" @@ -287,7 +287,7 @@ def test_scan_empty_csv_with_row_index(tmp_path: Path) -> None: assert read.collect().schema == OrderedDict([("idx", pl.UInt32), ("a", pl.String)]) -@pytest.mark.write_disk +@pytest.mark.write_disk() def test_csv_null_values_with_projection_15515() -> None: data = """IndCode,SireCode,BirthDate,Flag ID00316,.,19940315, @@ -309,7 +309,7 @@ def test_csv_null_values_with_projection_15515() -> None: } -@pytest.mark.write_disk +@pytest.mark.write_disk() def test_csv_respect_user_schema_ragged_lines_15254() -> None: with tempfile.NamedTemporaryFile() as f: f.write( diff --git a/py-polars/tests/unit/io/test_lazy_ipc.py b/py-polars/tests/unit/io/test_lazy_ipc.py index 0d67b6b06f89e..354a912ea4b61 100644 --- a/py-polars/tests/unit/io/test_lazy_ipc.py +++ b/py-polars/tests/unit/io/test_lazy_ipc.py @@ -11,7 +11,7 @@ from pathlib import Path -@pytest.fixture +@pytest.fixture() def foods_ipc_path(io_files_path: Path) -> Path: return io_files_path / "foods1.ipc" diff --git a/py-polars/tests/unit/io/test_lazy_json.py b/py-polars/tests/unit/io/test_lazy_json.py index a5a53d78f94cd..3ecd6f538f0a3 100644 --- a/py-polars/tests/unit/io/test_lazy_json.py +++ b/py-polars/tests/unit/io/test_lazy_json.py @@ -11,7 +11,7 @@ from pathlib import Path -@pytest.fixture +@pytest.fixture() def foods_ndjson_path(io_files_path: Path) -> Path: return io_files_path / "foods1.ndjson" @@ -66,7 +66,7 @@ def test_scan_ndjson_batch_size_zero() -> None: pl.scan_ndjson("test.ndjson", batch_size=0) -@pytest.mark.write_disk +@pytest.mark.write_disk() def test_scan_with_projection(tmp_path: Path) -> None: tmp_path.mkdir(exist_ok=True) diff --git a/py-polars/tests/unit/io/test_lazy_parquet.py b/py-polars/tests/unit/io/test_lazy_parquet.py index 68f7431354b54..7596322d8748c 100644 --- a/py-polars/tests/unit/io/test_lazy_parquet.py +++ b/py-polars/tests/unit/io/test_lazy_parquet.py @@ -16,12 +16,12 @@ from polars._typing import ParallelStrategy -@pytest.fixture +@pytest.fixture() def parquet_file_path(io_files_path: Path) -> Path: return io_files_path / "small.parquet" -@pytest.fixture +@pytest.fixture() def foods_parquet_path(io_files_path: Path) -> Path: return io_files_path / "foods1.parquet" @@ -65,7 +65,7 @@ def test_row_index_len_16543(foods_parquet_path: Path) -> None: assert q.select(pl.all()).select(pl.len()).collect().item() == 27 -@pytest.mark.write_disk +@pytest.mark.write_disk() def test_categorical_parquet_statistics(tmp_path: Path) -> None: tmp_path.mkdir(exist_ok=True) @@ -104,7 +104,7 @@ def test_categorical_parquet_statistics(tmp_path: Path) -> None: assert df.shape == (4, 3) -@pytest.mark.write_disk +@pytest.mark.write_disk() def test_parquet_eq_stats(tmp_path: Path) -> None: tmp_path.mkdir(exist_ok=True) @@ -125,7 +125,7 @@ def test_parquet_eq_stats(tmp_path: Path) -> None: ) -@pytest.mark.write_disk +@pytest.mark.write_disk() def test_parquet_is_in_stats(tmp_path: Path) -> None: tmp_path.mkdir(exist_ok=True) @@ -165,7 +165,7 @@ def test_parquet_is_in_stats(tmp_path: Path) -> None: ).collect().shape == (8, 1) -@pytest.mark.write_disk +@pytest.mark.write_disk() def test_parquet_stats(tmp_path: Path) -> None: tmp_path.mkdir(exist_ok=True) @@ -208,7 +208,7 @@ def test_row_index_schema_parquet(parquet_file_path: Path) -> None: ).dtypes == [pl.UInt32, pl.String] -@pytest.mark.write_disk +@pytest.mark.write_disk() def test_parquet_is_in_statistics(monkeypatch: Any, capfd: Any, tmp_path: Path) -> None: tmp_path.mkdir(exist_ok=True) @@ -244,7 +244,7 @@ def test_parquet_is_in_statistics(monkeypatch: Any, capfd: Any, tmp_path: Path) ) -@pytest.mark.write_disk +@pytest.mark.write_disk() def test_parquet_statistics(monkeypatch: Any, capfd: Any, tmp_path: Path) -> None: tmp_path.mkdir(exist_ok=True) @@ -280,7 +280,7 @@ def test_parquet_statistics(monkeypatch: Any, capfd: Any, tmp_path: Path) -> Non ) -@pytest.mark.write_disk +@pytest.mark.write_disk() def test_categorical(tmp_path: Path) -> None: tmp_path.mkdir(exist_ok=True) @@ -325,7 +325,7 @@ def test_glob_n_rows(io_files_path: Path) -> None: } -@pytest.mark.write_disk +@pytest.mark.write_disk() def test_parquet_statistics_filter_9925(tmp_path: Path) -> None: tmp_path.mkdir(exist_ok=True) file_path = tmp_path / "codes.parquet" @@ -338,7 +338,7 @@ def test_parquet_statistics_filter_9925(tmp_path: Path) -> None: assert q.collect().to_dict(as_series=False) == {"code": [300964, 300972, 26]} -@pytest.mark.write_disk +@pytest.mark.write_disk() def test_parquet_statistics_filter_11069(tmp_path: Path) -> None: tmp_path.mkdir(exist_ok=True) file_path = tmp_path / "foo.parquet" @@ -359,7 +359,7 @@ def test_parquet_list_arg(io_files_path: Path) -> None: assert df.row(0) == ("vegetables", 45, 0.5, 2) -@pytest.mark.write_disk +@pytest.mark.write_disk() def test_parquet_many_row_groups_12297(tmp_path: Path) -> None: tmp_path.mkdir(exist_ok=True) file_path = tmp_path / "foo.parquet" @@ -368,7 +368,7 @@ def test_parquet_many_row_groups_12297(tmp_path: Path) -> None: assert_frame_equal(pl.scan_parquet(file_path).collect(), df) -@pytest.mark.write_disk +@pytest.mark.write_disk() def test_row_index_empty_file(tmp_path: Path) -> None: tmp_path.mkdir(exist_ok=True) file_path = tmp_path / "test.parquet" @@ -378,7 +378,7 @@ def test_row_index_empty_file(tmp_path: Path) -> None: assert result.schema == OrderedDict([("idx", pl.UInt32), ("a", pl.Float32)]) -@pytest.mark.write_disk +@pytest.mark.write_disk() def test_io_struct_async_12500(tmp_path: Path) -> None: file_path = tmp_path / "test.parquet" pl.DataFrame( @@ -392,7 +392,7 @@ def test_io_struct_async_12500(tmp_path: Path) -> None: ) == {"c1": [{"a": "foo", "b": "bar"}]} -@pytest.mark.write_disk +@pytest.mark.write_disk() @pytest.mark.parametrize("streaming", [True, False]) def test_parquet_different_schema(tmp_path: Path, streaming: bool) -> None: # Schema is different but the projected columns are same dtype. @@ -409,7 +409,7 @@ def test_parquet_different_schema(tmp_path: Path, streaming: bool) -> None: ).columns == ["b"] -@pytest.mark.write_disk +@pytest.mark.write_disk() def test_nested_slice_12480(tmp_path: Path) -> None: path = tmp_path / "data.parquet" df = pl.select(pl.lit(1).repeat_by(10_000).explode().cast(pl.List(pl.Int32))) @@ -419,7 +419,7 @@ def test_nested_slice_12480(tmp_path: Path) -> None: assert pl.scan_parquet(path).slice(0, 1).collect().height == 1 -@pytest.mark.write_disk +@pytest.mark.write_disk() def test_scan_deadlock_rayon_spawn_from_async_15172( monkeypatch: Any, tmp_path: Path ) -> None: @@ -443,7 +443,7 @@ def scan_collect() -> None: assert results[0].equals(df) -@pytest.mark.write_disk +@pytest.mark.write_disk() @pytest.mark.parametrize("streaming", [True, False]) def test_parquet_schema_mismatch_panic_17067(tmp_path: Path, streaming: bool) -> None: pl.DataFrame({"a": [1, 2, 3], "b": [4, 5, 6]}).write_parquet(tmp_path / "1.parquet") @@ -453,7 +453,7 @@ def test_parquet_schema_mismatch_panic_17067(tmp_path: Path, streaming: bool) -> pl.scan_parquet(tmp_path).collect(streaming=streaming) -@pytest.mark.write_disk +@pytest.mark.write_disk() def test_predicate_push_down_categorical_17744(tmp_path: Path) -> None: path = tmp_path / "1" diff --git a/py-polars/tests/unit/io/test_other.py b/py-polars/tests/unit/io/test_other.py index 4c08250838d8b..d6562911adbbe 100644 --- a/py-polars/tests/unit/io/test_other.py +++ b/py-polars/tests/unit/io/test_other.py @@ -124,7 +124,7 @@ def test_unit_io_subdir_has_no_init() -> None: ).exists(), "Found undesirable '__init__.py' in the 'unit.io' tests subdirectory" -@pytest.mark.write_disk +@pytest.mark.write_disk() @pytest.mark.parametrize( ("scan_funcs", "write_func"), [ diff --git a/py-polars/tests/unit/io/test_parquet.py b/py-polars/tests/unit/io/test_parquet.py index 2d2e9cbaca341..2fd7d2ab41938 100644 --- a/py-polars/tests/unit/io/test_parquet.py +++ b/py-polars/tests/unit/io/test_parquet.py @@ -54,7 +54,7 @@ def test_scan_round_trip(tmp_path: Path, df: pl.DataFrame) -> None: ] -@pytest.mark.write_disk +@pytest.mark.write_disk() def test_write_parquet_using_pyarrow_9753(tmp_path: Path) -> None: tmp_path.mkdir(exist_ok=True) @@ -94,7 +94,7 @@ def test_write_parquet_using_pyarrow_write_to_dataset_with_partitioning( assert_frame_equal(df, read_df) -@pytest.fixture +@pytest.fixture() def small_parquet_path(io_files_path: Path) -> Path: return io_files_path / "small.parquet" @@ -149,7 +149,7 @@ def test_to_from_buffer_lzo(df: pl.DataFrame) -> None: _ = pl.read_parquet(buf) -@pytest.mark.write_disk +@pytest.mark.write_disk() @pytest.mark.parametrize("compression", COMPRESSIONS) def test_to_from_file( df: pl.DataFrame, compression: ParquetCompression, tmp_path: Path @@ -162,7 +162,7 @@ def test_to_from_file( assert_frame_equal(df, read_df, categorical_as_str=True) -@pytest.mark.write_disk +@pytest.mark.write_disk() def test_to_from_file_lzo(df: pl.DataFrame, tmp_path: Path) -> None: tmp_path.mkdir(exist_ok=True) @@ -246,7 +246,7 @@ def test_nested_parquet() -> None: assert isinstance(read.dtypes[0].inner, pl.datatypes.Struct) -@pytest.mark.write_disk +@pytest.mark.write_disk() def test_glob_parquet(df: pl.DataFrame, tmp_path: Path) -> None: tmp_path.mkdir(exist_ok=True) file_path = tmp_path / "small.parquet" @@ -279,7 +279,7 @@ def test_chunked_round_trip() -> None: assert_frame_equal(pl.read_parquet(f), df) -@pytest.mark.write_disk +@pytest.mark.write_disk() def test_lazy_self_join_file_cache_prop_3979(df: pl.DataFrame, tmp_path: Path) -> None: tmp_path.mkdir(exist_ok=True) @@ -431,7 +431,7 @@ def test_parquet_nested_dictionaries_6217() -> None: assert_frame_equal(read, df) # type: ignore[arg-type] -@pytest.mark.write_disk +@pytest.mark.write_disk() def test_fetch_union(tmp_path: Path) -> None: tmp_path.mkdir(exist_ok=True) @@ -457,7 +457,7 @@ def test_fetch_union(tmp_path: Path) -> None: assert_frame_equal(result_glob, expected) -@pytest.mark.slow +@pytest.mark.slow() def test_struct_pyarrow_dataset_5796(tmp_path: Path) -> None: tmp_path.mkdir(exist_ok=True) @@ -472,7 +472,7 @@ def test_struct_pyarrow_dataset_5796(tmp_path: Path) -> None: assert_frame_equal(result, df) # type: ignore[arg-type] -@pytest.mark.slow +@pytest.mark.slow() @pytest.mark.parametrize("case", [1048576, 1048577]) def test_parquet_chunks_545(case: int) -> None: f = io.BytesIO() @@ -585,7 +585,7 @@ def test_nested_struct_read_12610() -> None: assert_frame_equal(expect, actual) -@pytest.mark.write_disk +@pytest.mark.write_disk() def test_decimal_parquet(tmp_path: Path) -> None: path = tmp_path / "foo.parquet" df = pl.DataFrame( @@ -602,7 +602,7 @@ def test_decimal_parquet(tmp_path: Path) -> None: assert out == {"foo": [2], "bar": [Decimal("7")]} -@pytest.mark.write_disk +@pytest.mark.write_disk() def test_enum_parquet(tmp_path: Path) -> None: path = tmp_path / "enum.parquet" df = pl.DataFrame( @@ -630,7 +630,7 @@ def test_parquet_rle_non_nullable_12814() -> None: assert_frame_equal(expect, actual) -@pytest.mark.slow +@pytest.mark.slow() def test_parquet_12831() -> None: n = 70_000 df = pl.DataFrame({"x": ["aaaaaa"] * n}) @@ -640,7 +640,7 @@ def test_parquet_12831() -> None: assert_frame_equal(pl.from_arrow(pq.read_table(f)), df) # type: ignore[arg-type] -@pytest.mark.write_disk +@pytest.mark.write_disk() def test_parquet_struct_categorical(tmp_path: Path) -> None: tmp_path.mkdir(exist_ok=True) @@ -659,7 +659,7 @@ def test_parquet_struct_categorical(tmp_path: Path) -> None: assert out.to_dict(as_series=False) == {"b": [{"b": "foo", "count": 1}]} -@pytest.mark.write_disk +@pytest.mark.write_disk() def test_null_parquet(tmp_path: Path) -> None: tmp_path.mkdir(exist_ok=True) @@ -670,7 +670,7 @@ def test_null_parquet(tmp_path: Path) -> None: assert_frame_equal(out, df) -@pytest.mark.write_disk +@pytest.mark.write_disk() def test_write_parquet_with_null_col(tmp_path: Path) -> None: tmp_path.mkdir(exist_ok=True) @@ -685,7 +685,7 @@ def test_write_parquet_with_null_col(tmp_path: Path) -> None: assert_frame_equal(out, df) -@pytest.mark.write_disk +@pytest.mark.write_disk() def test_read_parquet_binary_buffered_reader(tmp_path: Path) -> None: tmp_path.mkdir(exist_ok=True) @@ -698,7 +698,7 @@ def test_read_parquet_binary_buffered_reader(tmp_path: Path) -> None: assert_frame_equal(out, df) -@pytest.mark.write_disk +@pytest.mark.write_disk() def test_read_parquet_binary_file_io(tmp_path: Path) -> None: tmp_path.mkdir(exist_ok=True) @@ -712,7 +712,7 @@ def test_read_parquet_binary_file_io(tmp_path: Path) -> None: # https://github.com/pola-rs/polars/issues/15760 -@pytest.mark.write_disk +@pytest.mark.write_disk() def test_read_parquet_binary_fsspec(tmp_path: Path) -> None: tmp_path.mkdir(exist_ok=True) @@ -919,7 +919,7 @@ def test_parquet_array_dtype_nulls() -> None: ), ], ) -@pytest.mark.write_disk +@pytest.mark.write_disk() def test_complex_types(tmp_path: Path, series: list[Any], dtype: pl.DataType) -> None: xs = pl.Series(series, dtype=dtype) df = pl.DataFrame({"x": xs}) @@ -927,13 +927,13 @@ def test_complex_types(tmp_path: Path, series: list[Any], dtype: pl.DataType) -> test_round_trip(df) -@pytest.mark.xfail +@pytest.mark.xfail() def test_placeholder_zero_array() -> None: # @TODO: if this does not fail anymore please enable the upper test-cases pl.Series([[]], dtype=pl.Array(pl.Int8, 0)) -@pytest.mark.write_disk +@pytest.mark.write_disk() def test_parquet_array_statistics(tmp_path: Path) -> None: tmp_path.mkdir(exist_ok=True) @@ -949,8 +949,8 @@ def test_parquet_array_statistics(tmp_path: Path) -> None: assert result.to_dict(as_series=False) == {"a": [[4, 5, 6], [7, 8, 9]], "b": [2, 3]} -@pytest.mark.slow -@pytest.mark.write_disk +@pytest.mark.slow() +@pytest.mark.write_disk() def test_read_parquet_only_loads_selected_columns_15098( memory_usage_without_pyarrow: MemoryUsage, tmp_path: Path ) -> None: @@ -980,8 +980,8 @@ def test_read_parquet_only_loads_selected_columns_15098( assert 8_000_000 < memory_usage_without_pyarrow.get_peak() < 13_000_000 -@pytest.mark.release -@pytest.mark.write_disk +@pytest.mark.release() +@pytest.mark.write_disk() def test_max_statistic_parquet_writer(tmp_path: Path) -> None: # this hits the maximal page size # so the row group will be split into multiple pages @@ -1000,7 +1000,7 @@ def test_max_statistic_parquet_writer(tmp_path: Path) -> None: assert_frame_equal(result, expected) -@pytest.mark.slow +@pytest.mark.slow() def test_hybrid_rle() -> None: # 10_007 elements to test if not a nice multiple of 8 n = 10_007 @@ -1087,8 +1087,8 @@ def test_hybrid_rle() -> None: max_size=5000, ) ) -@pytest.mark.slow -@pytest.mark.write_disk +@pytest.mark.slow() +@pytest.mark.write_disk() @settings(suppress_health_check=[HealthCheck.function_scoped_fixture]) def test_roundtrip_parametric(df: pl.DataFrame, tmp_path: Path) -> None: # delete if exists @@ -1112,7 +1112,7 @@ def test_parquet_statistics_uint64_16683() -> None: assert statistics.max == u64_max -@pytest.mark.slow +@pytest.mark.slow() @pytest.mark.parametrize("nullable", [True, False]) def test_read_byte_stream_split(nullable: bool) -> None: rng = np.random.default_rng(123) @@ -1144,7 +1144,7 @@ def test_read_byte_stream_split(nullable: bool) -> None: assert_frame_equal(read, df) -@pytest.mark.slow +@pytest.mark.slow() @pytest.mark.parametrize("rows_nullable", [True, False]) @pytest.mark.parametrize("item_nullable", [True, False]) def test_read_byte_stream_split_arrays( @@ -1207,7 +1207,7 @@ def test_read_byte_stream_split_arrays( assert_frame_equal(read, df) -@pytest.mark.write_disk +@pytest.mark.write_disk() def test_parquet_nested_null_array_17795(tmp_path: Path) -> None: filename = tmp_path / "nested_null.parquet" @@ -1215,7 +1215,7 @@ def test_parquet_nested_null_array_17795(tmp_path: Path) -> None: pq.read_table(filename) -@pytest.mark.write_disk +@pytest.mark.write_disk() def test_parquet_record_batches_pyarrow_fixed_size_list_16614(tmp_path: Path) -> None: filename = tmp_path / "a.parquet" @@ -1235,7 +1235,7 @@ def test_parquet_record_batches_pyarrow_fixed_size_list_16614(tmp_path: Path) -> assert_frame_equal(b, x) -@pytest.mark.write_disk +@pytest.mark.write_disk() def test_parquet_list_element_field_name(tmp_path: Path) -> None: filename = tmp_path / "list.parquet" @@ -1368,7 +1368,7 @@ def test_parquet_high_nested_null_17805( ) -@pytest.mark.write_disk +@pytest.mark.write_disk() def test_struct_plain_encoded_statistics(tmp_path: Path) -> None: df = pl.DataFrame( { @@ -1536,7 +1536,7 @@ def test_delta_strings_encoding_roundtrip( deadline=None, suppress_health_check=[HealthCheck.function_scoped_fixture], ) -@pytest.mark.write_disk +@pytest.mark.write_disk() def test_predicate_filtering( tmp_path: Path, df: pl.DataFrame, @@ -1584,7 +1584,7 @@ def test_predicate_filtering( @settings( suppress_health_check=[HealthCheck.function_scoped_fixture], ) -@pytest.mark.write_disk +@pytest.mark.write_disk() def test_slice_roundtrip( df: pl.DataFrame, offset: int, length: int, tmp_path: Path ) -> None: @@ -1600,7 +1600,7 @@ def test_slice_roundtrip( assert_frame_equal(scanned, df.slice(offset, length)) -@pytest.mark.write_disk +@pytest.mark.write_disk() def test_struct_prefiltered(tmp_path: Path) -> None: tmp_path.mkdir(exist_ok=True) f = tmp_path / "test.parquet" @@ -1641,7 +1641,7 @@ def test_struct_prefiltered(tmp_path: Path) -> None: ], ) @pytest.mark.parametrize("nullable", [False, True]) -@pytest.mark.write_disk +@pytest.mark.write_disk() def test_nested_skip_18303( data: tuple[list[dict[str, str] | list[str]], pa.DataType], nullable: bool, @@ -1697,7 +1697,7 @@ def test_nested_span_multiple_pages_18400() -> None: include_cols=[column("filter_col", pl.Boolean, allow_null=False)], ), ) -@pytest.mark.write_disk +@pytest.mark.write_disk() @settings( suppress_health_check=[HealthCheck.function_scoped_fixture], ) @@ -1760,7 +1760,7 @@ def test_different_page_validity_across_pages(value: str | int | float | bool) - deadline=None, suppress_health_check=[HealthCheck.function_scoped_fixture], ) -@pytest.mark.write_disk +@pytest.mark.write_disk() def test_delta_length_byte_array_prefiltering( tmp_path: Path, df: pl.DataFrame, @@ -1801,7 +1801,7 @@ def test_delta_length_byte_array_prefiltering( deadline=None, suppress_health_check=[HealthCheck.function_scoped_fixture], ) -@pytest.mark.write_disk +@pytest.mark.write_disk() def test_general_prefiltering( tmp_path: Path, df: pl.DataFrame, diff --git a/py-polars/tests/unit/io/test_scan.py b/py-polars/tests/unit/io/test_scan.py index 1bcc463bd2e7f..8476b8b5f6664 100644 --- a/py-polars/tests/unit/io/test_scan.py +++ b/py-polars/tests/unit/io/test_scan.py @@ -190,7 +190,7 @@ def data_file( raise NotImplementedError() -@pytest.mark.write_disk +@pytest.mark.write_disk() def test_scan( capfd: Any, monkeypatch: pytest.MonkeyPatch, data_file: _DataFile, force_async: bool ) -> None: @@ -205,7 +205,7 @@ def test_scan( assert_frame_equal(df, data_file.df) -@pytest.mark.write_disk +@pytest.mark.write_disk() def test_scan_with_limit( capfd: Any, monkeypatch: pytest.MonkeyPatch, data_file: _DataFile, force_async: bool ) -> None: @@ -227,7 +227,7 @@ def test_scan_with_limit( ) -@pytest.mark.write_disk +@pytest.mark.write_disk() def test_scan_with_filter( capfd: Any, monkeypatch: pytest.MonkeyPatch, data_file: _DataFile, force_async: bool ) -> None: @@ -253,7 +253,7 @@ def test_scan_with_filter( ) -@pytest.mark.write_disk +@pytest.mark.write_disk() def test_scan_with_filter_and_limit( capfd: Any, monkeypatch: pytest.MonkeyPatch, data_file: _DataFile, force_async: bool ) -> None: @@ -280,7 +280,7 @@ def test_scan_with_filter_and_limit( ) -@pytest.mark.write_disk +@pytest.mark.write_disk() def test_scan_with_limit_and_filter( capfd: Any, monkeypatch: pytest.MonkeyPatch, data_file: _DataFile, force_async: bool ) -> None: @@ -307,7 +307,7 @@ def test_scan_with_limit_and_filter( ) -@pytest.mark.write_disk +@pytest.mark.write_disk() def test_scan_with_row_index_and_limit( capfd: Any, monkeypatch: pytest.MonkeyPatch, data_file: _DataFile, force_async: bool ) -> None: @@ -335,7 +335,7 @@ def test_scan_with_row_index_and_limit( ) -@pytest.mark.write_disk +@pytest.mark.write_disk() def test_scan_with_row_index_and_filter( capfd: Any, monkeypatch: pytest.MonkeyPatch, data_file: _DataFile, force_async: bool ) -> None: @@ -363,7 +363,7 @@ def test_scan_with_row_index_and_filter( ) -@pytest.mark.write_disk +@pytest.mark.write_disk() def test_scan_with_row_index_limit_and_filter( capfd: Any, monkeypatch: pytest.MonkeyPatch, data_file: _DataFile, force_async: bool ) -> None: @@ -392,7 +392,7 @@ def test_scan_with_row_index_limit_and_filter( ) -@pytest.mark.write_disk +@pytest.mark.write_disk() def test_scan_with_row_index_projected_out( capfd: Any, monkeypatch: pytest.MonkeyPatch, data_file: _DataFile, force_async: bool ) -> None: @@ -415,7 +415,7 @@ def test_scan_with_row_index_projected_out( assert_frame_equal(df, data_file.df.select(subset)) -@pytest.mark.write_disk +@pytest.mark.write_disk() def test_scan_with_row_index_filter_and_limit( capfd: Any, monkeypatch: pytest.MonkeyPatch, data_file: _DataFile, force_async: bool ) -> None: @@ -447,7 +447,7 @@ def test_scan_with_row_index_filter_and_limit( ) -@pytest.mark.write_disk +@pytest.mark.write_disk() @pytest.mark.parametrize( ("scan_func", "write_func"), [ @@ -474,7 +474,7 @@ def test_scan_limit_0_does_not_panic( assert_frame_equal(scan_func(path).head(0).collect(streaming=streaming), df.clear()) -@pytest.mark.write_disk +@pytest.mark.write_disk() @pytest.mark.parametrize( ("scan_func", "write_func"), [ @@ -526,7 +526,7 @@ def test_scan_directory( assert_frame_equal(out, df) -@pytest.mark.write_disk +@pytest.mark.write_disk() def test_scan_glob_excludes_directories(tmp_path: Path) -> None: for dir in ["dir1", "dir2", "dir3"]: (tmp_path / dir).mkdir() @@ -546,7 +546,7 @@ def test_scan_glob_excludes_directories(tmp_path: Path) -> None: @pytest.mark.parametrize("file_name", ["a b", "a %25 b"]) -@pytest.mark.write_disk +@pytest.mark.write_disk() def test_scan_async_whitespace_in_path( tmp_path: Path, monkeypatch: Any, file_name: str ) -> None: @@ -563,7 +563,7 @@ def test_scan_async_whitespace_in_path( path.unlink() -@pytest.mark.write_disk +@pytest.mark.write_disk() def test_path_expansion_excludes_empty_files_17362(tmp_path: Path) -> None: tmp_path.mkdir(exist_ok=True) @@ -575,7 +575,7 @@ def test_path_expansion_excludes_empty_files_17362(tmp_path: Path) -> None: assert_frame_equal(pl.scan_parquet(tmp_path / "*").collect(), df) -@pytest.mark.write_disk +@pytest.mark.write_disk() def test_scan_single_dir_differing_file_extensions_raises_17436(tmp_path: Path) -> None: tmp_path.mkdir(exist_ok=True) @@ -619,7 +619,7 @@ def test_scan_nonexistent_path(format: str) -> None: result.collect() -@pytest.mark.write_disk +@pytest.mark.write_disk() @pytest.mark.parametrize( ("scan_func", "write_func"), [ @@ -682,7 +682,7 @@ def test_scan_include_file_name( assert_frame_equal(lf.head(0).collect(streaming=streaming), df.head(0)) -@pytest.mark.write_disk +@pytest.mark.write_disk() def test_async_path_expansion_bracket_17629(tmp_path: Path) -> None: path = tmp_path / "data.parquet" diff --git a/py-polars/tests/unit/io/test_spreadsheet.py b/py-polars/tests/unit/io/test_spreadsheet.py index 06af29659ba09..8869affa1e1bd 100644 --- a/py-polars/tests/unit/io/test_spreadsheet.py +++ b/py-polars/tests/unit/io/test_spreadsheet.py @@ -22,61 +22,61 @@ pytestmark = pytest.mark.slow() -@pytest.fixture +@pytest.fixture() def path_xls(io_files_path: Path) -> Path: # old excel 97-2004 format return io_files_path / "example.xls" -@pytest.fixture +@pytest.fixture() def path_xlsx(io_files_path: Path) -> Path: # modern excel format return io_files_path / "example.xlsx" -@pytest.fixture +@pytest.fixture() def path_xlsb(io_files_path: Path) -> Path: # excel binary format return io_files_path / "example.xlsb" -@pytest.fixture +@pytest.fixture() def path_ods(io_files_path: Path) -> Path: # open document spreadsheet return io_files_path / "example.ods" -@pytest.fixture +@pytest.fixture() def path_xls_empty(io_files_path: Path) -> Path: return io_files_path / "empty.xls" -@pytest.fixture +@pytest.fixture() def path_xlsx_empty(io_files_path: Path) -> Path: return io_files_path / "empty.xlsx" -@pytest.fixture +@pytest.fixture() def path_xlsx_mixed(io_files_path: Path) -> Path: return io_files_path / "mixed.xlsx" -@pytest.fixture +@pytest.fixture() def path_xlsb_empty(io_files_path: Path) -> Path: return io_files_path / "empty.xlsb" -@pytest.fixture +@pytest.fixture() def path_xlsb_mixed(io_files_path: Path) -> Path: return io_files_path / "mixed.xlsb" -@pytest.fixture +@pytest.fixture() def path_ods_empty(io_files_path: Path) -> Path: return io_files_path / "empty.ods" -@pytest.fixture +@pytest.fixture() def path_ods_mixed(io_files_path: Path) -> Path: return io_files_path / "mixed.ods" diff --git a/py-polars/tests/unit/lazyframe/test_engine_selection.py b/py-polars/tests/unit/lazyframe/test_engine_selection.py index cb4156989b696..760f63f6baa85 100644 --- a/py-polars/tests/unit/lazyframe/test_engine_selection.py +++ b/py-polars/tests/unit/lazyframe/test_engine_selection.py @@ -11,7 +11,7 @@ from polars._typing import EngineType -@pytest.fixture +@pytest.fixture() def df() -> pl.LazyFrame: return pl.LazyFrame({"a": [1, 2, 3]}) diff --git a/py-polars/tests/unit/lazyframe/test_lazyframe.py b/py-polars/tests/unit/lazyframe/test_lazyframe.py index 23394110b40e7..730a51d0b4935 100644 --- a/py-polars/tests/unit/lazyframe/test_lazyframe.py +++ b/py-polars/tests/unit/lazyframe/test_lazyframe.py @@ -1309,7 +1309,7 @@ def test_compare_schema_between_lazy_and_eager_6904() -> None: assert eager_result.shape == lazy_result.shape -@pytest.mark.slow +@pytest.mark.slow() @pytest.mark.parametrize( "dtype", [ diff --git a/py-polars/tests/unit/lazyframe/test_serde.py b/py-polars/tests/unit/lazyframe/test_serde.py index a82e389b4583a..86a5c932b7f55 100644 --- a/py-polars/tests/unit/lazyframe/test_serde.py +++ b/py-polars/tests/unit/lazyframe/test_serde.py @@ -47,7 +47,7 @@ def test_lf_serde_roundtrip_json(lf: pl.LazyFrame) -> None: assert_frame_equal(result, lf, categorical_as_str=True) -@pytest.fixture +@pytest.fixture() def lf() -> pl.LazyFrame: """Sample LazyFrame for testing serialization/deserialization.""" return pl.LazyFrame({"a": [1, 2, 3], "b": ["a", "b", "c"]}).select("a").sum() @@ -86,7 +86,7 @@ def test_lf_serde_to_from_buffer( assert_frame_equal(lf, result) -@pytest.mark.write_disk +@pytest.mark.write_disk() def test_lf_serde_to_from_file(lf: pl.LazyFrame, tmp_path: Path) -> None: tmp_path.mkdir(exist_ok=True) @@ -103,7 +103,7 @@ def test_lf_deserialize_validation() -> None: pl.LazyFrame.deserialize(f, format="json") -@pytest.mark.write_disk +@pytest.mark.write_disk() def test_lf_serde_scan(tmp_path: Path) -> None: tmp_path.mkdir(exist_ok=True) path = tmp_path / "dataset.parquet" diff --git a/py-polars/tests/unit/meta/test_versions.py b/py-polars/tests/unit/meta/test_versions.py index 944f921ac1fbc..89e0c301807ff 100644 --- a/py-polars/tests/unit/meta/test_versions.py +++ b/py-polars/tests/unit/meta/test_versions.py @@ -5,7 +5,7 @@ import polars as pl -@pytest.mark.slow +@pytest.mark.slow() def test_show_versions(capsys: Any) -> None: pl.show_versions() diff --git a/py-polars/tests/unit/ml/test_to_jax.py b/py-polars/tests/unit/ml/test_to_jax.py index 0dbc4effca185..e18902a11348e 100644 --- a/py-polars/tests/unit/ml/test_to_jax.py +++ b/py-polars/tests/unit/ml/test_to_jax.py @@ -20,7 +20,7 @@ from polars._typing import PolarsDataType -@pytest.fixture +@pytest.fixture() def df() -> pl.DataFrame: return pl.DataFrame( { diff --git a/py-polars/tests/unit/ml/test_to_torch.py b/py-polars/tests/unit/ml/test_to_torch.py index 2dc8f41410258..c42c6f2ea6664 100644 --- a/py-polars/tests/unit/ml/test_to_torch.py +++ b/py-polars/tests/unit/ml/test_to_torch.py @@ -15,7 +15,7 @@ pytestmark = pytest.mark.ci_only -@pytest.fixture +@pytest.fixture() def df() -> pl.DataFrame: return pl.DataFrame( { diff --git a/py-polars/tests/unit/operations/aggregation/test_aggregations.py b/py-polars/tests/unit/operations/aggregation/test_aggregations.py index 8667b419d59e5..ff6b272803825 100644 --- a/py-polars/tests/unit/operations/aggregation/test_aggregations.py +++ b/py-polars/tests/unit/operations/aggregation/test_aggregations.py @@ -113,7 +113,7 @@ def test_quantile() -> None: assert s.quantile(0.5, "higher") == 2 -@pytest.mark.slow +@pytest.mark.slow() @pytest.mark.parametrize("tp", [int, float]) @pytest.mark.parametrize("n", [1, 2, 10, 100]) def test_quantile_vs_numpy(tp: type, n: int) -> None: @@ -437,7 +437,7 @@ def test_agg_filter_over_empty_df_13610() -> None: assert_frame_equal(out, expected) -@pytest.mark.slow +@pytest.mark.slow() def test_agg_empty_sum_after_filter_14734() -> None: f = ( pl.DataFrame({"a": [1, 2], "b": [1, 2]}) @@ -462,7 +462,7 @@ def test_agg_empty_sum_after_filter_14734() -> None: assert_frame_equal(expect, curr.select("b")) -@pytest.mark.slow +@pytest.mark.slow() def test_grouping_hash_14749() -> None: n_groups = 251 rows_per_group = 4 @@ -543,7 +543,7 @@ def test_group_count_over_null_column_15705() -> None: assert out["c"].to_list() == [0, 0, 0] -@pytest.mark.release +@pytest.mark.release() def test_min_max_2850() -> None: # https://github.com/pola-rs/polars/issues/2850 df = pl.DataFrame( diff --git a/py-polars/tests/unit/operations/aggregation/test_vertical.py b/py-polars/tests/unit/operations/aggregation/test_vertical.py index fc74fdf59b651..3f2dbe080c07a 100644 --- a/py-polars/tests/unit/operations/aggregation/test_vertical.py +++ b/py-polars/tests/unit/operations/aggregation/test_vertical.py @@ -57,7 +57,7 @@ def test_alias_for_col_agg(function: str, input: str) -> None: assert_expr_equal(result, expected, context) -@pytest.mark.release +@pytest.mark.release() def test_mean_overflow() -> None: np.random.seed(1) expected = 769.5607652 diff --git a/py-polars/tests/unit/operations/namespaces/conftest.py b/py-polars/tests/unit/operations/namespaces/conftest.py index 6c017aa02e6e3..9aa3a121a35d4 100644 --- a/py-polars/tests/unit/operations/namespaces/conftest.py +++ b/py-polars/tests/unit/operations/namespaces/conftest.py @@ -5,6 +5,6 @@ import pytest -@pytest.fixture +@pytest.fixture() def namespace_files_path() -> Path: return Path(__file__).parent / "files" diff --git a/py-polars/tests/unit/operations/namespaces/temporal/test_datetime.py b/py-polars/tests/unit/operations/namespaces/temporal/test_datetime.py index fb4ddee681467..cd4ee34bde713 100644 --- a/py-polars/tests/unit/operations/namespaces/temporal/test_datetime.py +++ b/py-polars/tests/unit/operations/namespaces/temporal/test_datetime.py @@ -21,12 +21,12 @@ from polars._utils.convert import string_to_zoneinfo as ZoneInfo -@pytest.fixture +@pytest.fixture() def series_of_int_dates() -> pl.Series: return pl.Series([10000, 20000, 30000], dtype=pl.Date) -@pytest.fixture +@pytest.fixture() def series_of_str_dates() -> pl.Series: return pl.Series(["2020-01-01 00:00:00.000000000", "2020-02-02 03:20:10.987654321"]) diff --git a/py-polars/tests/unit/operations/rolling/test_rolling.py b/py-polars/tests/unit/operations/rolling/test_rolling.py index 4ab0c18d4873d..d934683d645f3 100644 --- a/py-polars/tests/unit/operations/rolling/test_rolling.py +++ b/py-polars/tests/unit/operations/rolling/test_rolling.py @@ -22,7 +22,7 @@ from polars._typing import ClosedInterval, PolarsDataType, TimeUnit -@pytest.fixture +@pytest.fixture() def example_df() -> pl.DataFrame: return pl.DataFrame( { @@ -911,7 +911,7 @@ def test_rolling_median() -> None: ) -@pytest.mark.slow +@pytest.mark.slow() def test_rolling_median_2() -> None: np.random.seed(12) n = 1000 diff --git a/py-polars/tests/unit/operations/test_clip.py b/py-polars/tests/unit/operations/test_clip.py index 906f217a4ab63..af6b1965d039b 100644 --- a/py-polars/tests/unit/operations/test_clip.py +++ b/py-polars/tests/unit/operations/test_clip.py @@ -9,7 +9,7 @@ from polars.testing import assert_frame_equal -@pytest.fixture +@pytest.fixture() def clip_exprs() -> list[pl.Expr]: return [ pl.col("a").clip(pl.col("min"), pl.col("max")).alias("clip"), diff --git a/py-polars/tests/unit/operations/test_comparison.py b/py-polars/tests/unit/operations/test_comparison.py index 42535cff85a61..eb74f374f6a1b 100644 --- a/py-polars/tests/unit/operations/test_comparison.py +++ b/py-polars/tests/unit/operations/test_comparison.py @@ -307,7 +307,7 @@ def verify_total_ordering_broadcast( ] -@pytest.mark.slow +@pytest.mark.slow() @pytest.mark.parametrize("lhs", INTERESTING_FLOAT_VALUES) @pytest.mark.parametrize("rhs", INTERESTING_FLOAT_VALUES) def test_total_ordering_float_series(lhs: float | None, rhs: float | None) -> None: @@ -335,7 +335,7 @@ def test_total_ordering_float_series(lhs: float | None, rhs: float | None) -> No ] -@pytest.mark.slow +@pytest.mark.slow() @pytest.mark.parametrize("lhs", INTERESTING_STRING_VALUES) @pytest.mark.parametrize("rhs", INTERESTING_STRING_VALUES) def test_total_ordering_string_series(lhs: str | None, rhs: str | None) -> None: @@ -347,7 +347,7 @@ def test_total_ordering_string_series(lhs: str | None, rhs: str | None) -> None: verify_total_ordering_broadcast(lhs, rhs, "", pl.String) -@pytest.mark.slow +@pytest.mark.slow() @pytest.mark.parametrize("str_lhs", INTERESTING_STRING_VALUES) @pytest.mark.parametrize("str_rhs", INTERESTING_STRING_VALUES) def test_total_ordering_binary_series(str_lhs: str | None, str_rhs: str | None) -> None: diff --git a/py-polars/tests/unit/operations/test_filter.py b/py-polars/tests/unit/operations/test_filter.py index a09c625cbe5b3..eed550fac516b 100644 --- a/py-polars/tests/unit/operations/test_filter.py +++ b/py-polars/tests/unit/operations/test_filter.py @@ -257,7 +257,7 @@ def test_filter_horizontal_selector_15428() -> None: assert_frame_equal(df, expected_df) -@pytest.mark.slow +@pytest.mark.slow() @pytest.mark.parametrize( "dtype", [pl.Boolean, pl.Int8, pl.Int16, pl.Int32, pl.Int64, pl.String] ) diff --git a/py-polars/tests/unit/operations/test_group_by.py b/py-polars/tests/unit/operations/test_group_by.py index 3a5436b912992..a448a25c2370d 100644 --- a/py-polars/tests/unit/operations/test_group_by.py +++ b/py-polars/tests/unit/operations/test_group_by.py @@ -249,7 +249,7 @@ def test_group_by_median_by_dtype( assert_frame_equal(result, df_expected) -@pytest.fixture +@pytest.fixture() def df() -> pl.DataFrame: return pl.DataFrame( { @@ -642,7 +642,7 @@ def test_group_by_binary_agg_with_literal() -> None: assert out.to_dict(as_series=False) == {"id": ["a", "b"], "value": [[4, 6], [4, 6]]} -@pytest.mark.slow +@pytest.mark.slow() @pytest.mark.parametrize("dtype", [pl.Int32, pl.UInt32]) def test_overflow_mean_partitioned_group_by_5194(dtype: PolarsDataType) -> None: df = pl.DataFrame( @@ -924,7 +924,7 @@ def test_group_by_multiple_null_cols_15623() -> None: assert df.is_empty() -@pytest.mark.release +@pytest.mark.release() def test_categorical_vs_str_group_by() -> None: # this triggers the perfect hash table s = pl.Series("a", np.random.randint(0, 50, 100)) @@ -951,7 +951,7 @@ def test_categorical_vs_str_group_by() -> None: ) -@pytest.mark.release +@pytest.mark.release() def test_boolean_min_max_agg() -> None: np.random.seed(0) idx = np.random.randint(0, 500, 1000) diff --git a/py-polars/tests/unit/operations/test_join.py b/py-polars/tests/unit/operations/test_join.py index 0a9d7ab2d9fd4..10fee51882517 100644 --- a/py-polars/tests/unit/operations/test_join.py +++ b/py-polars/tests/unit/operations/test_join.py @@ -618,7 +618,7 @@ def test_full_outer_join_list_() -> None: } -@pytest.mark.slow +@pytest.mark.slow() def test_join_validation() -> None: def test_each_join_validation( unique: pl.DataFrame, duplicate: pl.DataFrame, on: str, how: JoinStrategy @@ -848,7 +848,7 @@ def test_join_list_non_numeric() -> None: } -@pytest.mark.slow +@pytest.mark.slow() def test_join_4_columns_with_validity() -> None: # join on 4 columns so we trigger combine validities # use 138 as that is 2 u64 and a remainder @@ -870,7 +870,7 @@ def test_join_4_columns_with_validity() -> None: ) -@pytest.mark.release +@pytest.mark.release() def test_cross_join() -> None: # triggers > 100 rows implementation # https://github.com/pola-rs/polars/blob/5f5acb2a523ce01bc710768b396762b8e69a9e07/polars/polars-core/src/frame/cross_join.rs#L34 @@ -881,7 +881,7 @@ def test_cross_join() -> None: assert_frame_equal(df2.join(df1, how="cross").slice(0, 100), out) -@pytest.mark.release +@pytest.mark.release() def test_cross_join_slice_pushdown() -> None: # this will likely go out of memory if we did not pushdown the slice df = ( diff --git a/py-polars/tests/unit/operations/test_sort.py b/py-polars/tests/unit/operations/test_sort.py index 6d67e83a418ac..6119797dfe08b 100644 --- a/py-polars/tests/unit/operations/test_sort.py +++ b/py-polars/tests/unit/operations/test_sort.py @@ -507,7 +507,7 @@ def test_sort_type_coercion_6892() -> None: } -@pytest.mark.slow +@pytest.mark.slow() def test_sort_row_fmt(str_ints_df: pl.DataFrame) -> None: # we sort nulls_last as this will always dispatch # to row_fmt and is the default in pandas @@ -736,7 +736,7 @@ def test_sort_descending_nulls_last(descending: bool, nulls_last: bool) -> None: ) -@pytest.mark.release +@pytest.mark.release() def test_sort_nan_1942() -> None: # https://github.com/pola-rs/polars/issues/1942 import time diff --git a/py-polars/tests/unit/operations/test_window.py b/py-polars/tests/unit/operations/test_window.py index ddf293d216c93..17df33d268dc4 100644 --- a/py-polars/tests/unit/operations/test_window.py +++ b/py-polars/tests/unit/operations/test_window.py @@ -454,7 +454,7 @@ def test_window_agg_list_null_15437() -> None: assert_frame_equal(output, expected) -@pytest.mark.release +@pytest.mark.release() def test_windows_not_cached() -> None: ldf = ( pl.DataFrame( diff --git a/py-polars/tests/unit/sql/test_conditional.py b/py-polars/tests/unit/sql/test_conditional.py index b2000ebe37b1a..21c9d0dc738bf 100644 --- a/py-polars/tests/unit/sql/test_conditional.py +++ b/py-polars/tests/unit/sql/test_conditional.py @@ -10,7 +10,7 @@ from polars.testing import assert_frame_equal -@pytest.fixture +@pytest.fixture() def foods_ipc_path() -> Path: return Path(__file__).parent.parent / "io" / "files" / "foods1.ipc" diff --git a/py-polars/tests/unit/sql/test_functions.py b/py-polars/tests/unit/sql/test_functions.py index 84f2ecd972bc9..04055eb01c034 100644 --- a/py-polars/tests/unit/sql/test_functions.py +++ b/py-polars/tests/unit/sql/test_functions.py @@ -9,7 +9,7 @@ from polars.testing import assert_frame_equal -@pytest.fixture +@pytest.fixture() def foods_ipc_path() -> Path: return Path(__file__).parent.parent / "io" / "files" / "foods1.ipc" diff --git a/py-polars/tests/unit/sql/test_group_by.py b/py-polars/tests/unit/sql/test_group_by.py index 08e4b236c8335..83e91e78ed5db 100644 --- a/py-polars/tests/unit/sql/test_group_by.py +++ b/py-polars/tests/unit/sql/test_group_by.py @@ -10,7 +10,7 @@ from polars.testing import assert_frame_equal -@pytest.fixture +@pytest.fixture() def foods_ipc_path() -> Path: return Path(__file__).parent.parent / "io" / "files" / "foods1.ipc" diff --git a/py-polars/tests/unit/sql/test_joins.py b/py-polars/tests/unit/sql/test_joins.py index 3a1e90bed1b42..97872d8bbdcc4 100644 --- a/py-polars/tests/unit/sql/test_joins.py +++ b/py-polars/tests/unit/sql/test_joins.py @@ -10,7 +10,7 @@ from polars.testing import assert_frame_equal -@pytest.fixture +@pytest.fixture() def foods_ipc_path() -> Path: return Path(__file__).parent.parent / "io" / "files" / "foods1.ipc" diff --git a/py-polars/tests/unit/sql/test_miscellaneous.py b/py-polars/tests/unit/sql/test_miscellaneous.py index 77aa60e08af83..1ecd08e01e258 100644 --- a/py-polars/tests/unit/sql/test_miscellaneous.py +++ b/py-polars/tests/unit/sql/test_miscellaneous.py @@ -10,7 +10,7 @@ from polars.testing import assert_frame_equal -@pytest.fixture +@pytest.fixture() def foods_ipc_path() -> Path: return Path(__file__).parent.parent / "io" / "files" / "foods1.ipc" diff --git a/py-polars/tests/unit/sql/test_operators.py b/py-polars/tests/unit/sql/test_operators.py index e42825259b343..278e0776f2d77 100644 --- a/py-polars/tests/unit/sql/test_operators.py +++ b/py-polars/tests/unit/sql/test_operators.py @@ -9,7 +9,7 @@ from polars.testing import assert_frame_equal -@pytest.fixture +@pytest.fixture() def foods_ipc_path() -> Path: return Path(__file__).parent.parent / "io" / "files" / "foods1.ipc" diff --git a/py-polars/tests/unit/sql/test_order_by.py b/py-polars/tests/unit/sql/test_order_by.py index 704ebd3e773e5..bd93743a416a3 100644 --- a/py-polars/tests/unit/sql/test_order_by.py +++ b/py-polars/tests/unit/sql/test_order_by.py @@ -8,7 +8,7 @@ from polars.exceptions import SQLInterfaceError, SQLSyntaxError -@pytest.fixture +@pytest.fixture() def foods_ipc_path() -> Path: return Path(__file__).parent.parent / "io" / "files" / "foods1.ipc" diff --git a/py-polars/tests/unit/sql/test_regex.py b/py-polars/tests/unit/sql/test_regex.py index af0b9a31fa674..ece4e02bd8fea 100644 --- a/py-polars/tests/unit/sql/test_regex.py +++ b/py-polars/tests/unit/sql/test_regex.py @@ -8,7 +8,7 @@ from polars.exceptions import SQLSyntaxError -@pytest.fixture +@pytest.fixture() def foods_ipc_path() -> Path: return Path(__file__).parent.parent / "io" / "files" / "foods1.ipc" diff --git a/py-polars/tests/unit/sql/test_strings.py b/py-polars/tests/unit/sql/test_strings.py index 46e3c645a85ae..c0c4883f0ddaf 100644 --- a/py-polars/tests/unit/sql/test_strings.py +++ b/py-polars/tests/unit/sql/test_strings.py @@ -10,7 +10,7 @@ # TODO: Do not rely on I/O for these tests -@pytest.fixture +@pytest.fixture() def foods_ipc_path() -> Path: return Path(__file__).parent.parent / "io" / "files" / "foods1.ipc" diff --git a/py-polars/tests/unit/sql/test_structs.py b/py-polars/tests/unit/sql/test_structs.py index ce324172502bd..fdd4040237134 100644 --- a/py-polars/tests/unit/sql/test_structs.py +++ b/py-polars/tests/unit/sql/test_structs.py @@ -7,7 +7,7 @@ from polars.testing import assert_frame_equal -@pytest.fixture +@pytest.fixture() def df_struct() -> pl.DataFrame: return pl.DataFrame( { diff --git a/py-polars/tests/unit/sql/test_table_operations.py b/py-polars/tests/unit/sql/test_table_operations.py index 8c3862b85b35b..73b544c9c0edb 100644 --- a/py-polars/tests/unit/sql/test_table_operations.py +++ b/py-polars/tests/unit/sql/test_table_operations.py @@ -10,7 +10,7 @@ from polars.testing import assert_frame_equal -@pytest.fixture +@pytest.fixture() def test_frame() -> pl.LazyFrame: return pl.LazyFrame( { diff --git a/py-polars/tests/unit/sql/test_wildcard_opts.py b/py-polars/tests/unit/sql/test_wildcard_opts.py index e27ce9ac14b30..d1fd6873bc3c5 100644 --- a/py-polars/tests/unit/sql/test_wildcard_opts.py +++ b/py-polars/tests/unit/sql/test_wildcard_opts.py @@ -9,7 +9,7 @@ from polars.testing import assert_frame_equal -@pytest.fixture +@pytest.fixture() def df() -> pl.DataFrame: return pl.DataFrame( { diff --git a/py-polars/tests/unit/streaming/conftest.py b/py-polars/tests/unit/streaming/conftest.py index d3c434edcc3e2..b7b476474316e 100644 --- a/py-polars/tests/unit/streaming/conftest.py +++ b/py-polars/tests/unit/streaming/conftest.py @@ -3,6 +3,6 @@ import pytest -@pytest.fixture +@pytest.fixture() def io_files_path() -> Path: return Path(__file__).parent.parent / "io" / "files" diff --git a/py-polars/tests/unit/streaming/test_streaming.py b/py-polars/tests/unit/streaming/test_streaming.py index 6f1738544bec9..9c8ae9a2d57b0 100644 --- a/py-polars/tests/unit/streaming/test_streaming.py +++ b/py-polars/tests/unit/streaming/test_streaming.py @@ -72,7 +72,7 @@ def test_streaming_streamable_functions(monkeypatch: Any, capfd: Any) -> None: assert "df -> function -> ordered_sink" in err -@pytest.mark.slow +@pytest.mark.slow() def test_cross_join_stack() -> None: a = pl.Series(np.arange(100_000)).to_frame().lazy() t0 = time.time() @@ -161,8 +161,8 @@ def test_streaming_sortedness_propagation_9494() -> None: } -@pytest.mark.write_disk -@pytest.mark.slow +@pytest.mark.write_disk() +@pytest.mark.slow() def test_streaming_generic_left_and_inner_join_from_disk(tmp_path: Path) -> None: tmp_path.mkdir(exist_ok=True) p0 = tmp_path / "df0.parquet" @@ -212,7 +212,7 @@ def test_streaming_9776() -> None: assert unordered.sort(["col_1", "ID"]).rows() == expected -@pytest.mark.write_disk +@pytest.mark.write_disk() def test_stream_empty_file(tmp_path: Path) -> None: p = tmp_path / "in.parquet" schema = { @@ -288,7 +288,7 @@ def test_boolean_agg_schema() -> None: ) -@pytest.mark.write_disk +@pytest.mark.write_disk() def test_streaming_csv_headers_but_no_data_13770(tmp_path: Path) -> None: with Path.open(tmp_path / "header_no_data.csv", "w") as f: f.write("name, age\n") @@ -303,7 +303,7 @@ def test_streaming_csv_headers_but_no_data_13770(tmp_path: Path) -> None: assert df.schema == schema -@pytest.mark.write_disk +@pytest.mark.write_disk() def test_custom_temp_dir(tmp_path: Path, monkeypatch: Any) -> None: tmp_path.mkdir(exist_ok=True) monkeypatch.setenv("POLARS_TEMP_DIR", str(tmp_path)) @@ -317,7 +317,7 @@ def test_custom_temp_dir(tmp_path: Path, monkeypatch: Any) -> None: assert os.listdir(tmp_path), f"Temp directory '{tmp_path}' is empty" -@pytest.mark.write_disk +@pytest.mark.write_disk() def test_streaming_with_hconcat(tmp_path: Path) -> None: df1 = pl.DataFrame( { diff --git a/py-polars/tests/unit/streaming/test_streaming_group_by.py b/py-polars/tests/unit/streaming/test_streaming_group_by.py index 561783f833a8c..de36443fc3a54 100644 --- a/py-polars/tests/unit/streaming/test_streaming_group_by.py +++ b/py-polars/tests/unit/streaming/test_streaming_group_by.py @@ -17,7 +17,7 @@ pytestmark = pytest.mark.xdist_group("streaming") -@pytest.mark.slow +@pytest.mark.slow() def test_streaming_group_by_sorted_fast_path_nulls_10273() -> None: df = pl.Series( name="x", @@ -207,7 +207,7 @@ def random_integers() -> pl.Series: return pl.Series("a", np.random.randint(0, 10, 100), dtype=pl.Int64) -@pytest.mark.write_disk +@pytest.mark.write_disk() def test_streaming_group_by_ooc_q1( random_integers: pl.Series, tmp_path: Path, @@ -235,7 +235,7 @@ def test_streaming_group_by_ooc_q1( assert_frame_equal(result, expected) -@pytest.mark.write_disk +@pytest.mark.write_disk() def test_streaming_group_by_ooc_q2( random_integers: pl.Series, tmp_path: Path, @@ -263,7 +263,7 @@ def test_streaming_group_by_ooc_q2( assert_frame_equal(result, expected) -@pytest.mark.write_disk +@pytest.mark.write_disk() def test_streaming_group_by_ooc_q3( random_integers: pl.Series, tmp_path: Path, @@ -306,7 +306,7 @@ def test_streaming_group_by_struct_key() -> None: } -@pytest.mark.slow +@pytest.mark.slow() def test_streaming_group_by_all_numeric_types_stability_8570() -> None: m = 1000 n = 1000 diff --git a/py-polars/tests/unit/streaming/test_streaming_io.py b/py-polars/tests/unit/streaming/test_streaming_io.py index ff526d609a0a4..3c1ec7fb24690 100644 --- a/py-polars/tests/unit/streaming/test_streaming_io.py +++ b/py-polars/tests/unit/streaming/test_streaming_io.py @@ -14,7 +14,7 @@ pytestmark = pytest.mark.xdist_group("streaming") -@pytest.mark.write_disk +@pytest.mark.write_disk() def test_streaming_parquet_glob_5900(df: pl.DataFrame, tmp_path: Path) -> None: tmp_path.mkdir(exist_ok=True) file_path = tmp_path / "small.parquet" @@ -47,7 +47,7 @@ def test_scan_csv_overwrite_small_dtypes( assert df.dtypes == [pl.String, pl.Int64, pl.Float64, dtype] -@pytest.mark.write_disk +@pytest.mark.write_disk() def test_sink_parquet(io_files_path: Path, tmp_path: Path) -> None: tmp_path.mkdir(exist_ok=True) @@ -64,7 +64,7 @@ def test_sink_parquet(io_files_path: Path, tmp_path: Path) -> None: assert_frame_equal(result, df_read) -@pytest.mark.write_disk +@pytest.mark.write_disk() def test_sink_parquet_10115(tmp_path: Path) -> None: in_path = tmp_path / "in.parquet" out_path = tmp_path / "out.parquet" @@ -89,7 +89,7 @@ def test_sink_parquet_10115(tmp_path: Path) -> None: } -@pytest.mark.write_disk +@pytest.mark.write_disk() def test_sink_ipc(io_files_path: Path, tmp_path: Path) -> None: tmp_path.mkdir(exist_ok=True) @@ -106,7 +106,7 @@ def test_sink_ipc(io_files_path: Path, tmp_path: Path) -> None: assert_frame_equal(result, df_read) -@pytest.mark.write_disk +@pytest.mark.write_disk() def test_sink_csv(io_files_path: Path, tmp_path: Path) -> None: source_file = io_files_path / "small.parquet" target_file = tmp_path / "sink.csv" @@ -119,7 +119,7 @@ def test_sink_csv(io_files_path: Path, tmp_path: Path) -> None: assert_frame_equal(target_data, source_data) -@pytest.mark.write_disk +@pytest.mark.write_disk() def test_sink_csv_14494(tmp_path: Path) -> None: pl.LazyFrame({"c": [1, 2, 3]}, schema={"c": pl.Int64}).filter( pl.col("c") > 10 @@ -194,7 +194,7 @@ def test_sink_csv_batch_size_zero() -> None: lf.sink_csv("test.csv", batch_size=0) -@pytest.mark.write_disk +@pytest.mark.write_disk() def test_sink_csv_nested_data(tmp_path: Path) -> None: tmp_path.mkdir(exist_ok=True) path = tmp_path / "data.csv" @@ -218,7 +218,7 @@ def test_scan_empty_csv_10818(io_files_path: Path) -> None: assert df.is_empty() -@pytest.mark.write_disk +@pytest.mark.write_disk() def test_streaming_cross_join_schema(tmp_path: Path) -> None: file_path = tmp_path / "temp.parquet" a = pl.DataFrame({"a": [1, 2]}).lazy() @@ -228,7 +228,7 @@ def test_streaming_cross_join_schema(tmp_path: Path) -> None: assert read.to_dict(as_series=False) == {"a": [1, 2], "b": ["b", "b"]} -@pytest.mark.write_disk +@pytest.mark.write_disk() def test_sink_ndjson_should_write_same_data( io_files_path: Path, tmp_path: Path ) -> None: @@ -246,7 +246,7 @@ def test_sink_ndjson_should_write_same_data( assert_frame_equal(df, expected) -@pytest.mark.write_disk +@pytest.mark.write_disk() def test_parquet_eq_statistics(monkeypatch: Any, capfd: Any, tmp_path: Path) -> None: tmp_path.mkdir(exist_ok=True) @@ -286,7 +286,7 @@ def test_parquet_eq_statistics(monkeypatch: Any, capfd: Any, tmp_path: Path) -> ) -@pytest.mark.write_disk +@pytest.mark.write_disk() def test_streaming_empty_parquet_16523(tmp_path: Path) -> None: file_path = tmp_path / "foo.parquet" df = pl.DataFrame({"a": []}, schema={"a": pl.Int32}) diff --git a/py-polars/tests/unit/streaming/test_streaming_join.py b/py-polars/tests/unit/streaming/test_streaming_join.py index 074110076b28e..5edc7456f7d63 100644 --- a/py-polars/tests/unit/streaming/test_streaming_join.py +++ b/py-polars/tests/unit/streaming/test_streaming_join.py @@ -269,7 +269,7 @@ def test_non_coalescing_streaming_left_join() -> None: } -@pytest.mark.write_disk +@pytest.mark.write_disk() def test_streaming_outer_join_partial_flush(tmp_path: Path) -> None: data = { "value_at": [datetime(2024, i + 1, 1) for i in range(6)], diff --git a/py-polars/tests/unit/streaming/test_streaming_sort.py b/py-polars/tests/unit/streaming/test_streaming_sort.py index 8388671bd717e..4973b51fa6238 100644 --- a/py-polars/tests/unit/streaming/test_streaming_sort.py +++ b/py-polars/tests/unit/streaming/test_streaming_sort.py @@ -73,8 +73,8 @@ def test_streaming_sort_multiple_columns_logical_types() -> None: assert_frame_equal(result, expected) -@pytest.mark.write_disk -@pytest.mark.slow +@pytest.mark.write_disk() +@pytest.mark.slow() def test_ooc_sort(tmp_path: Path, monkeypatch: Any) -> None: tmp_path.mkdir(exist_ok=True) monkeypatch.setenv("POLARS_TEMP_DIR", str(tmp_path)) @@ -92,8 +92,8 @@ def test_ooc_sort(tmp_path: Path, monkeypatch: Any) -> None: assert_series_equal(out, s.sort(descending=descending)) -@pytest.mark.debug -@pytest.mark.write_disk +@pytest.mark.debug() +@pytest.mark.write_disk() @pytest.mark.parametrize("spill_source", [True, False]) def test_streaming_sort( tmp_path: Path, monkeypatch: Any, capfd: Any, spill_source: bool @@ -119,7 +119,7 @@ def test_streaming_sort( assert "PARTITIONED FORCE SPILLED" in err -@pytest.mark.write_disk +@pytest.mark.write_disk() @pytest.mark.parametrize("spill_source", [True, False]) def test_out_of_core_sort_9503( tmp_path: Path, monkeypatch: Any, spill_source: bool @@ -183,8 +183,8 @@ def test_out_of_core_sort_9503( } -@pytest.mark.write_disk -@pytest.mark.slow +@pytest.mark.write_disk() +@pytest.mark.slow() def test_streaming_sort_multiple_columns( str_ints_df: pl.DataFrame, tmp_path: Path, monkeypatch: Any, capfd: Any ) -> None: diff --git a/py-polars/tests/unit/streaming/test_streaming_unique.py b/py-polars/tests/unit/streaming/test_streaming_unique.py index e477952a8c0b5..77d7534548dd8 100644 --- a/py-polars/tests/unit/streaming/test_streaming_unique.py +++ b/py-polars/tests/unit/streaming/test_streaming_unique.py @@ -13,8 +13,8 @@ pytestmark = pytest.mark.xdist_group("streaming") -@pytest.mark.write_disk -@pytest.mark.slow +@pytest.mark.write_disk() +@pytest.mark.slow() def test_streaming_out_of_core_unique( io_files_path: Path, tmp_path: Path, monkeypatch: Any, capfd: Any ) -> None: diff --git a/py-polars/tests/unit/test_api.py b/py-polars/tests/unit/test_api.py index a90bc5ceb68d5..57bd08a6cc87b 100644 --- a/py-polars/tests/unit/test_api.py +++ b/py-polars/tests/unit/test_api.py @@ -124,7 +124,7 @@ def square(self) -> pl.Series: ] -@pytest.mark.slow +@pytest.mark.slow() @pytest.mark.parametrize("pcls", [pl.Expr, pl.DataFrame, pl.LazyFrame, pl.Series]) def test_class_namespaces_are_registered(pcls: Any) -> None: # confirm that existing (and new) namespaces diff --git a/py-polars/tests/unit/test_config.py b/py-polars/tests/unit/test_config.py index e4f1a152ad7ba..d110975773f47 100644 --- a/py-polars/tests/unit/test_config.py +++ b/py-polars/tests/unit/test_config.py @@ -610,7 +610,7 @@ def test_numeric_right_alignment() -> None: ) -@pytest.mark.write_disk +@pytest.mark.write_disk() def test_config_load_save(tmp_path: Path) -> None: for file in ( None, diff --git a/py-polars/tests/unit/test_cpu_check.py b/py-polars/tests/unit/test_cpu_check.py index fdfa5965f6ff0..23525f5126ddf 100644 --- a/py-polars/tests/unit/test_cpu_check.py +++ b/py-polars/tests/unit/test_cpu_check.py @@ -6,7 +6,7 @@ from polars._cpu_check import check_cpu_flags -@pytest.fixture +@pytest.fixture() def _feature_flags(monkeypatch: pytest.MonkeyPatch) -> None: """Use the default set of feature flags.""" feature_flags = "+sse3,+ssse3" diff --git a/py-polars/tests/unit/test_cse.py b/py-polars/tests/unit/test_cse.py index c4b6466e51b7b..5a519dc94e2c8 100644 --- a/py-polars/tests/unit/test_cse.py +++ b/py-polars/tests/unit/test_cse.py @@ -145,7 +145,7 @@ def test_cse_9630() -> None: assert_frame_equal(result, expected) -@pytest.mark.write_disk +@pytest.mark.write_disk() def test_schema_row_index_cse() -> None: csv_a = NamedTemporaryFile() csv_a.write( @@ -181,7 +181,7 @@ def test_schema_row_index_cse() -> None: assert_frame_equal(result, expected) -@pytest.mark.debug +@pytest.mark.debug() def test_cse_expr_selection_context() -> None: q = pl.LazyFrame( { @@ -634,7 +634,7 @@ def test_cse_15548() -> None: assert len(ldf3.collect(comm_subplan_elim=True)) == 4 -@pytest.mark.debug +@pytest.mark.debug() def test_cse_and_schema_update_projection_pd() -> None: df = pl.LazyFrame({"a": [1, 2], "b": [99, 99]}) @@ -654,7 +654,7 @@ def test_cse_and_schema_update_projection_pd() -> None: assert num_cse_occurrences(q.explain(comm_subexpr_elim=True)) == 1 -@pytest.mark.debug +@pytest.mark.debug() def test_cse_predicate_self_join(capfd: Any, monkeypatch: Any) -> None: monkeypatch.setenv("POLARS_VERBOSE", "1") y = pl.LazyFrame({"a": [1], "b": [2], "y": [3]}) @@ -702,7 +702,7 @@ def test_cse_no_projection_15980() -> None: ) == {"x": ["a", "a"]} -@pytest.mark.debug +@pytest.mark.debug() def test_cse_series_collision_16138() -> None: holdings = pl.DataFrame( { diff --git a/py-polars/tests/unit/test_plugins.py b/py-polars/tests/unit/test_plugins.py index 60d14852a0d55..828ae80473066 100644 --- a/py-polars/tests/unit/test_plugins.py +++ b/py-polars/tests/unit/test_plugins.py @@ -15,7 +15,7 @@ ) -@pytest.mark.write_disk +@pytest.mark.write_disk() def test_register_plugin_function_invalid_plugin_path(tmp_path: Path) -> None: tmp_path.mkdir(exist_ok=True) plugin_path = tmp_path / "lib.so" @@ -44,7 +44,7 @@ def test_serialize_kwargs(input: dict[str, Any] | None, expected: bytes) -> None assert _serialize_kwargs(input) == expected -@pytest.mark.write_disk +@pytest.mark.write_disk() def test_resolve_plugin_path(tmp_path: Path) -> None: tmp_path.mkdir(exist_ok=True) @@ -63,7 +63,7 @@ def test_resolve_plugin_path(tmp_path: Path) -> None: assert result == expected -@pytest.mark.write_disk +@pytest.mark.write_disk() def test_resolve_plugin_path_raises(tmp_path: Path) -> None: tmp_path.mkdir(exist_ok=True) (tmp_path / "__init__.py").touch() @@ -72,7 +72,7 @@ def test_resolve_plugin_path_raises(tmp_path: Path) -> None: _resolve_plugin_path(tmp_path) -@pytest.mark.write_disk +@pytest.mark.write_disk() @pytest.mark.parametrize( ("path", "expected"), [ @@ -89,7 +89,7 @@ def test_is_dynamic_lib(path: Path, expected: bool, tmp_path: Path) -> None: assert _is_dynamic_lib(full_path) is expected -@pytest.mark.write_disk +@pytest.mark.write_disk() def test_is_dynamic_lib_dir(tmp_path: Path) -> None: path = Path("lib.so") full_path = tmp_path / path diff --git a/py-polars/tests/unit/test_polars_import.py b/py-polars/tests/unit/test_polars_import.py index fa1779de34782..ed9bad5a4a7af 100644 --- a/py-polars/tests/unit/test_polars_import.py +++ b/py-polars/tests/unit/test_polars_import.py @@ -67,7 +67,7 @@ def _import_timings_as_frame(n_tries: int) -> tuple[pl.DataFrame, int]: @pytest.mark.skipif(sys.platform == "win32", reason="Unreliable on Windows") -@pytest.mark.slow +@pytest.mark.slow() def test_polars_import() -> None: # up-front compile '.py' -> '.pyc' before timing polars_path = Path(pl.__file__).parent diff --git a/py-polars/tests/unit/test_selectors.py b/py-polars/tests/unit/test_selectors.py index cad0cfdac4c1d..e292e709a9707 100644 --- a/py-polars/tests/unit/test_selectors.py +++ b/py-polars/tests/unit/test_selectors.py @@ -30,7 +30,7 @@ def assert_repr_equals(item: Any, expected: str) -> None: assert repr(item) == expected -@pytest.fixture +@pytest.fixture() def df() -> pl.DataFrame: # set up an empty dataframe with plenty of columns of various dtypes df = pl.DataFrame( diff --git a/py-polars/tests/unit/testing/parametric/strategies/test_core.py b/py-polars/tests/unit/testing/parametric/strategies/test_core.py index 8edf018e6f213..bb54255f4d10a 100644 --- a/py-polars/tests/unit/testing/parametric/strategies/test_core.py +++ b/py-polars/tests/unit/testing/parametric/strategies/test_core.py @@ -170,13 +170,13 @@ def test_dataframes_columns(lf: pl.LazyFrame) -> None: assert all(v in xyz for v in df["d"].to_list()) -@pytest.mark.hypothesis +@pytest.mark.hypothesis() def test_column_invalid_probability() -> None: with pytest.deprecated_call(), pytest.raises(InvalidArgument): column("col", null_probability=2.0) -@pytest.mark.hypothesis +@pytest.mark.hypothesis() def test_column_null_probability_deprecated() -> None: with pytest.deprecated_call(): col = column("col", allow_null=False, null_probability=0.5) diff --git a/py-polars/tests/unit/testing/parametric/strategies/test_legacy.py b/py-polars/tests/unit/testing/parametric/strategies/test_legacy.py index d9cd5bc5bbb75..eab2574dc2d64 100644 --- a/py-polars/tests/unit/testing/parametric/strategies/test_legacy.py +++ b/py-polars/tests/unit/testing/parametric/strategies/test_legacy.py @@ -5,14 +5,14 @@ from polars.testing.parametric.strategies.core import _COL_LIMIT -@pytest.mark.hypothesis +@pytest.mark.hypothesis() def test_columns_deprecated() -> None: with pytest.deprecated_call(), pytest.warns(NonInteractiveExampleWarning): result = columns() assert 0 <= len(result) <= _COL_LIMIT -@pytest.mark.hypothesis +@pytest.mark.hypothesis() def test_create_list_strategy_deprecated() -> None: with pytest.deprecated_call(), pytest.warns(NonInteractiveExampleWarning): result = create_list_strategy(size=5) diff --git a/py-polars/tests/unit/utils/test_utils.py b/py-polars/tests/unit/utils/test_utils.py index f6eca92215dab..603d0a2e959a1 100644 --- a/py-polars/tests/unit/utils/test_utils.py +++ b/py-polars/tests/unit/utils/test_utils.py @@ -186,7 +186,7 @@ def test_parse_version(v1: Any, v2: Any) -> None: assert parse_version(v2) < parse_version(v1) -@pytest.mark.slow +@pytest.mark.slow() def test_in_notebook() -> None: # private function, but easier to test this separately and mock it in the callers assert not _in_notebook()