| 866 | assert a[1].b == 3 |
| 867 | |
| 868 | def test_duplicate_errors(self): |
| 869 | with pytest.raises(BoxError): |
| 870 | Box({"?a": 1, "!a": 3}, box_duplicates="error") |
| 871 | |
| 872 | Box({"?a": 1, "!a": 3}, box_duplicates="ignore") |
| 873 | |
| 874 | with pytest.warns(UserWarning) as warning: |
| 875 | Box({"?a": 1, "!a": 3}, box_duplicates="warn") |
| 876 | assert warning[0].message.args[0].startswith("Duplicate") |
| 877 | |
| 878 | my_box = Box({"?a": 1}, box_duplicates="error") |
| 879 | with pytest.raises(BoxError): |
| 880 | my_box["^a"] = 3 |
| 881 | |
| 882 | @pytest.mark.parametrize("policy", ["error", "warn"]) |
| 883 | @pytest.mark.parametrize("use_attribute", [False, True]) |