From 2329aff3ef365043bf1405523bfb765da2ffba6b Mon Sep 17 00:00:00 2001 From: Sammy Sidhu Date: Thu, 30 Nov 2023 21:00:33 -0800 Subject: [PATCH] reduce number of fixtures --- tests/expressions/typing/conftest.py | 29 ++++++++---------------- tests/expressions/typing/test_compare.py | 11 --------- 2 files changed, 9 insertions(+), 31 deletions(-) diff --git a/tests/expressions/typing/conftest.py b/tests/expressions/typing/conftest.py index 7347182c32..e48923b095 100644 --- a/tests/expressions/typing/conftest.py +++ b/tests/expressions/typing/conftest.py @@ -40,21 +40,6 @@ ALL_DATATYPES_BINARY_PAIRS = list(itertools.product(ALL_DTYPES, repeat=2)) -@pytest.fixture( - scope="module", - params=ALL_DATATYPES_BINARY_PAIRS, - ids=[f"{dt1}-{dt2}" for (dt1, _), (dt2, _) in ALL_DATATYPES_BINARY_PAIRS], -) -def binary_data_fixture(request) -> tuple[Series, Series]: - """Returns binary permutation of Series' of all DataType pairs""" - (dt1, data1), (dt2, data2) = request.param - s1 = Series.from_arrow(data1, name="lhs") - assert s1.datatype() == dt1 - s2 = Series.from_arrow(data2, name="rhs") - assert s2.datatype() == dt2 - return (s1, s2) - - ALL_TEMPORAL_DTYPES = [ (DataType.date(), pa.array([datetime.date(2021, 1, 1), datetime.date(2021, 1, 2), None], type=pa.date32())), *[ @@ -94,6 +79,8 @@ def binary_data_fixture(request) -> tuple[Series, Series]: ], ] +ALL_DTYPES += ALL_TEMPORAL_DTYPES + ALL_TEMPORAL_DATATYPES_BINARY_PAIRS = [ ((dt1, data1), (dt2, data2)) for (dt1, data1), (dt2, data2) in itertools.product(ALL_TEMPORAL_DTYPES, repeat=2) @@ -104,13 +91,15 @@ def binary_data_fixture(request) -> tuple[Series, Series]: ) ] +ALL_DATATYPES_BINARY_PAIRS += ALL_TEMPORAL_DATATYPES_BINARY_PAIRS + @pytest.fixture( scope="module", - params=ALL_TEMPORAL_DATATYPES_BINARY_PAIRS, - ids=[f"{dt1}-{dt2}" for (dt1, _), (dt2, _) in ALL_TEMPORAL_DATATYPES_BINARY_PAIRS], + params=ALL_DATATYPES_BINARY_PAIRS, + ids=[f"{dt1}-{dt2}" for (dt1, _), (dt2, _) in ALL_DATATYPES_BINARY_PAIRS], ) -def binary_temporal_data_fixture(request) -> tuple[Series, Series]: +def binary_data_fixture(request) -> tuple[Series, Series]: """Returns binary permutation of Series' of all DataType pairs""" (dt1, data1), (dt2, data2) = request.param s1 = Series.from_arrow(data1, name="lhs") @@ -122,8 +111,8 @@ def binary_temporal_data_fixture(request) -> tuple[Series, Series]: @pytest.fixture( scope="module", - params=ALL_DTYPES + ALL_TEMPORAL_DTYPES, - ids=[f"{dt}" for (dt, _) in ALL_DTYPES + ALL_TEMPORAL_DTYPES], + params=ALL_DTYPES, + ids=[f"{dt}" for (dt, _) in ALL_DTYPES], ) def unary_data_fixture(request) -> Series: """Returns unary permutation of Series' of all DataType pairs""" diff --git a/tests/expressions/typing/test_compare.py b/tests/expressions/typing/test_compare.py index 8c174cd0bb..9ab988e40c 100644 --- a/tests/expressions/typing/test_compare.py +++ b/tests/expressions/typing/test_compare.py @@ -26,14 +26,3 @@ def test_comparable(binary_data_fixture, op): run_kernel=lambda: op(lhs, rhs), resolvable=comparable_type_validation(lhs.datatype(), rhs.datatype()), ) - - -@pytest.mark.parametrize("op", [ops.eq, ops.ne, ops.lt, ops.le, ops.gt, ops.ge]) -def test_temporal_comparable(binary_temporal_data_fixture, op): - lhs, rhs = binary_temporal_data_fixture - assert_typing_resolve_vs_runtime_behavior( - data=binary_temporal_data_fixture, - expr=op(col(lhs.name()), col(rhs.name())), - run_kernel=lambda: op(lhs, rhs), - resolvable=comparable_type_validation(lhs.datatype(), rhs.datatype()), - )