Skip to content

Commit

Permalink
clean source_or_sink
Browse files Browse the repository at this point in the history
  • Loading branch information
lithomas1 committed Jun 27, 2024
1 parent c5a3fbe commit 79c1dfd
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions python/cudf/cudf/pylibcudf_tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,21 +126,18 @@ def _generate_struct_data(typ):


@pytest.fixture(
params=["a.txt", pathlib.Path("a.txt"), io.BytesIO(), io.StringIO()],
params=["a.txt", pathlib.Path("a.txt"), io.BytesIO, io.StringIO],
)
def source_or_sink(request, tmp_path):
fp_or_buf = request.param
if isinstance(fp_or_buf, str):
fp_or_buf = f"{tmp_path}/{fp_or_buf}"
return f"{tmp_path}/{fp_or_buf}"
elif isinstance(fp_or_buf, os.PathLike):
fp_or_buf = tmp_path.joinpath(fp_or_buf)

yield fp_or_buf
# Cleanup after ourselves
# since the BytesIO and StringIO objects get cached by pytest
if isinstance(fp_or_buf, io.IOBase):
fp_or_buf.seek(0)
fp_or_buf.truncate(0)
return tmp_path.joinpath(fp_or_buf)
elif issubclass(fp_or_buf, io.IOBase):
# Must construct io.StringIO/io.BytesIO inside
# fixture, or we'll end up re-using it
return fp_or_buf()


@pytest.fixture(
Expand Down

0 comments on commit 79c1dfd

Please sign in to comment.