Skip to content

Commit

Permalink
test(refactor): simplify expr/test_literal.py
Browse files Browse the repository at this point in the history
Preparing for ibis-project#8666
  • Loading branch information
NickCrews committed Jun 6, 2024
1 parent 2b921f8 commit 26017ad
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 additions & 13 deletions ibis/tests/expr/test_literal.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,33 +118,25 @@ def test_struct_literal(value):
@pytest.mark.parametrize(
"value",
[
dict(field1="value1", field3=3.14), # wrong field name
dict(field1="value1"), # missing field
pytest.param(dict(field1="value1", field3=3.14), id="wrong_field"),
pytest.param(dict(field1="value1"), id="missing_field"),
],
)
def test_struct_literal_non_castable(value):
typestr = "struct<field1: string, field2: float64>"
with pytest.raises(TypeError, match="Unable to normalize"):
ibis.struct(value, type=typestr)
ibis.struct(value, type="struct<field1: string, field2: float64>")


def test_struct_cast_to_empty_struct():
value = ibis.struct({"a": 1, "b": 2.0})
assert value.type().castable(dt.Struct({}))


@pytest.mark.parametrize(
"value",
[
dict(key1="value1", key2="value2"),
],
)
def test_map_literal(value):
typestr = "map<string, int8>"
def test_map_literal():
a = ibis.map(["a", "b"], [1, 2])
assert a.op().keys.value == ("a", "b")
assert a.op().values.value == (1, 2)
assert a.type() == dt.dtype(typestr)
assert a.type() == dt.dtype("map<string, int8>")


@pytest.mark.parametrize(
Expand Down

0 comments on commit 26017ad

Please sign in to comment.