MCPcopy Create free account
hub / github.com/cdgriffith/Box / TestReflectedOperatorsKeepOptions

Class TestReflectedOperatorsKeepOptions

test/test_review_fixes.py:14–44  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

12
13
14class TestReflectedOperatorsKeepOptions:
15 @pytest.mark.parametrize("op", ["|", "+"])
16 def test_plain_dict_on_the_left(self, op):
17 right = Sub({"b": {"c": 1}}, box_dots=True, default_box=True, camel_killer_box=True)
18 result = {"CamelKey": 1} | right if op == "|" else {"CamelKey": 1} + right
19 assert type(result) is Sub
20 for option in ("box_dots", "default_box", "camel_killer_box"):
21 assert result._box_config[option] is True, option
22 assert result["b.c"] == 1
23 assert result.camel_key == 1
24 assert result.missing == Sub()
25
26 def test_frozen_right_side(self):
27 right = Box({"b": 2}, frozen_box=True)
28 for result in ({"a": 1} | right, {"a": 1} + right):
29 assert result.to_dict() == {"a": 1, "b": 2}
30 with pytest.raises(BoxError):
31 result.c = 3
32 assert right.to_dict() == {"b": 2}
33
34 def test_order_rules_unchanged(self):
35 right = Box({"a": 2, "b": 2}, box_dots=True)
36 assert ({"a": 1} | right).to_dict() == {"a": 2, "b": 2}
37 assert ({"a": 1} + right).to_dict() == {"a": 2, "b": 2}
38 assert (right | {"a": 1}).to_dict() == {"a": 1, "b": 2}
39
40 def test_left_operand_is_not_changed(self):
41 left = {"a": {"x": 1}}
42 result = left | Box(box_dots=True)
43 result["a.x"] = 2
44 assert left == {"a": {"x": 1}}
45
46
47class TestDefaultBoxAttrFactories:

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected