more reorg
This commit is contained in:
@@ -89,6 +89,7 @@ class TestDAGSetBasicOps:
|
||||
class TestDAGSetCallbacks:
|
||||
"""Test callback mechanisms."""
|
||||
|
||||
class TestBasicOps:
|
||||
def test_on_add_callback(self) -> None:
|
||||
added: list[int] = []
|
||||
s = DAGSetView({1, 2})
|
||||
@@ -110,86 +111,7 @@ class TestDAGSetCallbacks:
|
||||
assert s.on_add is None
|
||||
assert s.on_remove is None
|
||||
|
||||
|
||||
class TestDAGSetInPlaceOperators:
|
||||
"""Test in-place set operators."""
|
||||
|
||||
class TestDAGSetIOR:
|
||||
def test_set(self) -> None:
|
||||
s = DAGSetView({1, 2})
|
||||
s |= {3, 4}
|
||||
assert set(s) == {1, 2, 3, 4}
|
||||
|
||||
def test_list(self) -> None:
|
||||
s = DAGSetView({1})
|
||||
s |= [2, 3]
|
||||
assert set(s) == {1, 2, 3}
|
||||
|
||||
def test_string(self) -> None:
|
||||
s = DAGSetView({"abc", "def"})
|
||||
s |= "xyz"
|
||||
assert "xyz" in s
|
||||
|
||||
class TestDAGSetIAdd:
|
||||
pass
|
||||
|
||||
class TestDAGSetISub:
|
||||
pass
|
||||
|
||||
def test_iadd_with_set(self) -> None:
|
||||
s = DAGSetView({1, 2})
|
||||
s += {3, 4}
|
||||
assert set(s) == {1, 2, 3, 4}
|
||||
|
||||
def test_iadd_with_list(self) -> None:
|
||||
s = DAGSetView({1})
|
||||
s += [2, 3]
|
||||
assert set(s) == {1, 2, 3}
|
||||
|
||||
def test_iadd_with_string(self) -> None:
|
||||
s = DAGSetView({"a"})
|
||||
s += "b"
|
||||
assert "b" in s
|
||||
|
||||
def test_isub_with_set(self) -> None:
|
||||
s = DAGSetView({1, 2, 3, 4})
|
||||
s -= {2, 3}
|
||||
assert set(s) == {1, 4}
|
||||
|
||||
def test_isub_with_list(self) -> None:
|
||||
s = DAGSetView({1, 2, 3})
|
||||
s -= [2]
|
||||
assert set(s) == {1, 3}
|
||||
|
||||
def test_isub_with_string(self) -> None:
|
||||
s = DAGSetView({"a", "b", "c"})
|
||||
s -= "b"
|
||||
assert set(s) == {"a", "c"}
|
||||
|
||||
def test_iand_with_set(self) -> None:
|
||||
s = DAGSetView({1, 2, 3})
|
||||
s &= {2, 3, 4}
|
||||
assert set(s) == {2, 3}
|
||||
|
||||
def test_iand_with_list(self) -> None:
|
||||
s = DAGSetView({1, 2, 3})
|
||||
s &= [2, 3]
|
||||
assert set(s) == {2, 3}
|
||||
|
||||
def test_ixor_with_set(self) -> None:
|
||||
s = DAGSetView({1, 2, 3})
|
||||
s ^= {3, 4, 5}
|
||||
assert set(s) == {1, 2, 4, 5}
|
||||
|
||||
def test_ixor_with_list(self) -> None:
|
||||
s = DAGSetView({1, 2})
|
||||
s ^= [2, 3]
|
||||
assert set(s) == {1, 3}
|
||||
|
||||
|
||||
class TestDAGSetCallbacksWithOperators:
|
||||
"""Test that callbacks fire with in-place operators."""
|
||||
|
||||
class TestInPlaceOperators:
|
||||
def test_ior_triggers_callbacks(self) -> None:
|
||||
added: list[int] = []
|
||||
s = DAGSetView({1})
|
||||
@@ -213,3 +135,78 @@ class TestDAGSetCallbacksWithOperators:
|
||||
s -= {2, 3}
|
||||
assert 2 in removed
|
||||
assert 3 in removed
|
||||
|
||||
|
||||
|
||||
class TestDAGSetInPlaceOperators:
|
||||
"""Test in-place set operators."""
|
||||
|
||||
class TestIOR:
|
||||
def test_set(self) -> None:
|
||||
s = DAGSetView({1, 2})
|
||||
s |= {3, 4}
|
||||
assert set(s) == {1, 2, 3, 4}
|
||||
|
||||
def test_list(self) -> None:
|
||||
s = DAGSetView({1})
|
||||
s |= [2, 3]
|
||||
assert set(s) == {1, 2, 3}
|
||||
|
||||
def test_string(self) -> None:
|
||||
s = DAGSetView({"abc", "def"})
|
||||
s |= "xyz"
|
||||
assert "xyz" in s
|
||||
|
||||
class TestIAdd:
|
||||
def test_set(self) -> None:
|
||||
s = DAGSetView({1, 2})
|
||||
s += {3, 4}
|
||||
assert set(s) == {1, 2, 3, 4}
|
||||
|
||||
def test_list(self) -> None:
|
||||
s = DAGSetView({1})
|
||||
s += [2, 3]
|
||||
assert set(s) == {1, 2, 3}
|
||||
|
||||
def test_string(self) -> None:
|
||||
s = DAGSetView({"a"})
|
||||
s += "b"
|
||||
assert "b" in s
|
||||
|
||||
class TestISub:
|
||||
def test_set(self) -> None:
|
||||
s = DAGSetView({1, 2, 3, 4})
|
||||
s -= {2, 3}
|
||||
assert set(s) == {1, 4}
|
||||
|
||||
def test_list(self) -> None:
|
||||
s = DAGSetView({1, 2, 3})
|
||||
s -= [2]
|
||||
assert set(s) == {1, 3}
|
||||
|
||||
def test_string(self) -> None:
|
||||
s = DAGSetView({"a", "b", "c"})
|
||||
s -= "b"
|
||||
assert set(s) == {"a", "c"}
|
||||
|
||||
class TestIAnd:
|
||||
def test_set(self) -> None:
|
||||
s = DAGSetView({1, 2, 3})
|
||||
s &= {2, 3, 4}
|
||||
assert set(s) == {2, 3}
|
||||
|
||||
def test_list(self) -> None:
|
||||
s = DAGSetView({1, 2, 3})
|
||||
s &= [2, 3]
|
||||
assert set(s) == {2, 3}
|
||||
|
||||
class TestIXor:
|
||||
def test_set(self) -> None:
|
||||
s = DAGSetView({1, 2, 3})
|
||||
s ^= {3, 4, 5}
|
||||
assert set(s) == {1, 2, 4, 5}
|
||||
|
||||
def test_list(self) -> None:
|
||||
s = DAGSetView({1, 2})
|
||||
s ^= [2, 3]
|
||||
assert set(s) == {1, 3}
|
||||
|
||||
Reference in New Issue
Block a user