| 817 | assert a[1].b == 3 |
| 818 | |
| 819 | def test_duplicate_errors(self): |
| 820 | with pytest.raises(BoxError): |
| 821 | Box({"?a": 1, "!a": 3}, box_duplicates="error") |
| 822 | |
| 823 | Box({"?a": 1, "!a": 3}, box_duplicates="ignore") |
| 824 | |
| 825 | with pytest.warns(UserWarning) as warning: |
| 826 | Box({"?a": 1, "!a": 3}, box_duplicates="warn") |
| 827 | assert warning[0].message.args[0].startswith("Duplicate") |
| 828 | |
| 829 | my_box = Box({"?a": 1}, box_duplicates="error") |
| 830 | with pytest.raises(BoxError): |
| 831 | my_box["^a"] = 3 |
| 832 | |
| 833 | @pytest.mark.parametrize("policy", ["error", "warn"]) |
| 834 | @pytest.mark.parametrize("use_attribute", [False, True]) |