| 405 | del bx._box_config |
| 406 | |
| 407 | def test_setting_method_names(self): |
| 408 | # Box's own converters are protected keys |
| 409 | for name in ("to_msgpack", "from_msgpack", "to_toon", "from_toon", "to_json"): |
| 410 | with pytest.raises(BoxKeyError, match="protected"): |
| 411 | setattr(Box(), name, 1) |
| 412 | |
| 413 | # Other class attributes are stored as keys, the method still wins for attribute access |
| 414 | class Described(Box): |
| 415 | label = "class attribute" |
| 416 | |
| 417 | def describe(self): |
| 418 | return "method" |
| 419 | |
| 420 | bx = Described() |
| 421 | bx.describe = 1 |
| 422 | bx.label = 2 |
| 423 | assert bx.to_dict() == {"describe": 1, "label": 2} |
| 424 | assert bx.describe() == "method" |
| 425 | |
| 426 | |
| 427 | class TestFrozen: |