Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(python): fixes issue with relative location of file used in namespace tests #11588

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions py-polars/tests/unit/io/test_csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand Down
10 changes: 10 additions & 0 deletions py-polars/tests/unit/namespaces/conftest.py
Original file line number Diff line number Diff line change
@@ -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"
11 changes: 6 additions & 5 deletions py-polars/tests/unit/namespaces/test_meta.py
Original file line number Diff line number Diff line change
@@ -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")
Expand Down Expand Up @@ -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]
Expand Down