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

tests: guard pyarrow use in tests with pytest.importorskip (allows testing on 3.12) #386

Merged
merged 6 commits into from
Oct 12, 2023
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
8 changes: 4 additions & 4 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,19 +60,19 @@ def ndjson_points_file_str(ndjson_points1_str: str) -> str:


@pytest.fixture(scope="session")
def daa_old(ndjson_points1: str) -> dak.Array:
def daa(ndjson_points1: str) -> dak.Array:
return dak.from_json([ndjson_points1] * 3)


@pytest.fixture(scope="session")
def pq_points_dir(daa_old: dak.Array, tmp_path_factory: pytest.TempPathFactory) -> str:
def pq_points_dir(daa: dak.Array, tmp_path_factory: pytest.TempPathFactory) -> str:
pqdir = tmp_path_factory.mktemp("pqfiles")
dak.to_parquet(daa_old, str(pqdir))
dak.to_parquet(daa, str(pqdir))
return str(pqdir)


@pytest.fixture(scope="session")
def daa(pq_points_dir: str) -> dak.Array:
def daa_parquet(pq_points_dir: str) -> dak.Array:
return dak.from_parquet(pq_points_dir)


Expand Down
6 changes: 4 additions & 2 deletions tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,9 @@ def test_clear_divisions(ndjson_points_file: str) -> None:
assert not daa.known_divisions


def test_dunder_str(daa: Array) -> None:
assert str(daa) == "dask.awkward<from-parquet, npartitions=3>"
def test_dunder_str(caa: ak.Array) -> None:
daa = dak.from_awkward(caa, npartitions=2)
assert str(daa) == "dask.awkward<from-awkward, npartitions=2>"


def test_calculate_known_divisions(ndjson_points_file: str) -> None:
Expand Down Expand Up @@ -820,6 +821,7 @@ def test_map_partitions_no_dask_collections_passed(caa):

@pytest.mark.parametrize("fn", [dak.count, dak.zeros_like, dak.ones_like])
def test_shape_only_ops(fn: Callable, tmp_path_factory: pytest.TempPathFactory) -> None:
pytest.importorskip("pyarrow")
a = ak.Array([{"a": 1, "b": 2}, {"a": 3, "b": 4}])
p = tmp_path_factory.mktemp("zeros-like-flat")
ak.to_parquet(a, str(p / "file.parquet"))
Expand Down
4 changes: 3 additions & 1 deletion tests/test_io_text.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@
import awkward as ak
import awkward.operations.str as akstr
import fsspec
import pytest

import dask_awkward as dak
from dask_awkward.lib.testutils import assert_eq


def test_form_text() -> None:
def test_from_text() -> None:
pytest.importorskip("pyarrow")
f1 = "https://raw.githubusercontent.com/dask-contrib/dask-awkward/main/README.md"
f2 = "https://raw.githubusercontent.com/dask-contrib/dask-awkward/main/LICENSE"

Expand Down
10 changes: 5 additions & 5 deletions tests/test_optimize.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
from dask_awkward.lib.testutils import assert_eq


def test_multiple_computes(pq_points_dir: str) -> None:
ds1 = dak.from_parquet(pq_points_dir)
# add a columns= argument to force a new tokenize result in
# from_parquet so we get two unique collections.
ds2 = dak.from_parquet(pq_points_dir, columns=["points"])
def test_multiple_computes(ndjson_points_file: str) -> None:
ds1 = dak.from_json([ndjson_points_file] * 2)
# add a kwarg argument to force a new tokenize result in
# from_json so we get two unique collections.
ds2 = dak.from_json([ndjson_points_file] * 2, buffersize=65536 // 2)

lists = [[[1, 2, 3], [4, 5]], [[], [0, 0, 0]]]
ds3 = dak.from_lists(lists)
Expand Down
2 changes: 2 additions & 0 deletions tests/test_structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,8 @@ def test_isclose(daa, caa):


def test_singletons(daa, L4, tmp_path):
pytest.importorskip("pyarrow")

import warnings

path = str(tmp_path)
Expand Down
Loading