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

Method test_setting_method_names

test/test_edge_cases.py:407–424  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

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
427class TestFrozen:

Callers

nothing calls this directly

Calls 4

describeMethod · 0.95
BoxClass · 0.90
DescribedClass · 0.85
to_dictMethod · 0.80

Tested by

no test coverage detected