Skip to content

Commit

Permalink
refactor(test): don't abuse pytest fixtures when simple constants work
Browse files Browse the repository at this point in the history
  • Loading branch information
NickCrews committed Jan 26, 2025
1 parent a410d3b commit 0044845
Showing 1 changed file with 9 additions and 35 deletions.
44 changes: 9 additions & 35 deletions ibis/tests/expr/test_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,37 +23,26 @@
from ibis.expr.types import Column, Table
from ibis.tests.util import assert_equal, assert_pickle_roundtrip


@pytest.fixture
def set_ops_schema_top():
return [("key", "string"), ("value", "double")]


@pytest.fixture
def set_ops_schema_bottom():
return [("key", "string"), ("key2", "string"), ("value", "double")]
set_ops_schema_top = [("key", "string"), ("value", "double")]
set_ops_schema_bottom = [("key", "string"), ("key2", "string"), ("value", "double")]
setops_relation_error_message = "Table schemas must be equal for set operations"


@pytest.fixture
def setops_table_foo(set_ops_schema_top):
def setops_table_foo():
return ibis.table(set_ops_schema_top, "foo")


@pytest.fixture
def setops_table_bar(set_ops_schema_top):
def setops_table_bar():
return ibis.table(set_ops_schema_top, "bar")


@pytest.fixture
def setops_table_baz(set_ops_schema_bottom):
def setops_table_baz():
return ibis.table(set_ops_schema_bottom, "baz")


@pytest.fixture
def setops_relation_error_message():
return "Table schemas must be equal for set operations"


def test_empty_schema():
table = api.table([], "foo")
assert not table.schema()
Expand Down Expand Up @@ -1376,12 +1365,7 @@ def test_unravel_compound_equijoin(table):
assert joined.op() == expected


def test_union(
setops_table_foo,
setops_table_bar,
setops_table_baz,
setops_relation_error_message,
):
def test_union(setops_table_foo, setops_table_bar, setops_table_baz: Table):
result = setops_table_foo.union(setops_table_bar)
assert isinstance(result.op(), ops.Union)
assert not result.op().distinct
Expand All @@ -1393,25 +1377,15 @@ def test_union(
setops_table_foo.union(setops_table_baz)


def test_intersection(
setops_table_foo,
setops_table_bar,
setops_table_baz,
setops_relation_error_message,
):
def test_intersection(setops_table_foo, setops_table_bar, setops_table_baz):
result = setops_table_foo.intersect(setops_table_bar)
assert isinstance(result.op(), ops.Intersection)

with pytest.raises(RelationError, match=setops_relation_error_message):
setops_table_foo.intersect(setops_table_baz)


def test_difference(
setops_table_foo,
setops_table_bar,
setops_table_baz,
setops_relation_error_message,
):
def test_difference(setops_table_foo, setops_table_bar, setops_table_baz):
result = setops_table_foo.difference(setops_table_bar)
assert isinstance(result.op(), ops.Difference)

Expand Down

0 comments on commit 0044845

Please sign in to comment.