diff --git a/py-polars/tests/unit/io/test_csv.py b/py-polars/tests/unit/io/test_csv.py index 49df41ce4795..0afa8b30b3cd 100644 --- a/py-polars/tests/unit/io/test_csv.py +++ b/py-polars/tests/unit/io/test_csv.py @@ -728,6 +728,7 @@ def test_write_csv_delimiter() -> None: df.write_csv(f, separator="\t") f.seek(0) assert f.read() == b"a\tb\n1\t1\n2\t2\n3\t3\n" + assert_frame_equal(df, pl.read_csv(f, separator="\t")) def test_write_csv_line_terminator() -> None: @@ -736,6 +737,7 @@ def test_write_csv_line_terminator() -> None: df.write_csv(f, line_terminator="\r\n") f.seek(0) assert f.read() == b"a,b\r\n1,1\r\n2,2\r\n3,3\r\n" + assert_frame_equal(df, pl.read_csv(f, eol_char="\n")) def test_escaped_null_values() -> None: diff --git a/py-polars/tests/unit/namespaces/conftest.py b/py-polars/tests/unit/namespaces/conftest.py new file mode 100644 index 000000000000..9aa3a121a35d --- /dev/null +++ b/py-polars/tests/unit/namespaces/conftest.py @@ -0,0 +1,10 @@ +from __future__ import annotations + +from pathlib import Path + +import pytest + + +@pytest.fixture() +def namespace_files_path() -> Path: + return Path(__file__).parent / "files" diff --git a/py-polars/tests/unit/namespaces/test_tree_fmt.txt b/py-polars/tests/unit/namespaces/files/test_tree_fmt.txt similarity index 100% rename from py-polars/tests/unit/namespaces/test_tree_fmt.txt rename to py-polars/tests/unit/namespaces/files/test_tree_fmt.txt diff --git a/py-polars/tests/unit/namespaces/test_meta.py b/py-polars/tests/unit/namespaces/test_meta.py index 21e7e6671296..b8c79b056bd3 100644 --- a/py-polars/tests/unit/namespaces/test_meta.py +++ b/py-polars/tests/unit/namespaces/test_meta.py @@ -1,11 +1,14 @@ from __future__ import annotations -from pathlib import Path +from typing import TYPE_CHECKING import pytest import polars as pl +if TYPE_CHECKING: + from pathlib import Path + def test_meta_pop_and_cmp() -> None: e = pl.col("foo").alias("bar") @@ -70,10 +73,8 @@ def test_meta_is_regex_projection() -> None: assert e.meta.has_multiple_outputs() -def test_meta_tree_format() -> None: - with Path("tests/unit/namespaces/test_tree_fmt.txt").open( - "r", encoding="utf-8" - ) as f: +def test_meta_tree_format(namespace_files_path: Path) -> None: + with (namespace_files_path / "test_tree_fmt.txt").open("r", encoding="utf-8") as f: test_sets = f.read().split("---") for test_set in test_sets: expression = test_set.strip().split("\n")[0]