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

Class DefaultMapping

test/test_strict_box.py:426–447  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

424
425
426class DefaultMapping(MutableMapping):
427 def __init__(self):
428 self.data = {}
429 self.defaulted = []
430
431 def __getitem__(self, key):
432 if key not in self.data:
433 self.defaulted.append(key)
434 self.data[key] = None
435 return self.data[key]
436
437 def __setitem__(self, key, value):
438 self.data[key] = value
439
440 def __delitem__(self, key):
441 del self.data[key]
442
443 def __iter__(self):
444 return iter(self.data)
445
446 def __len__(self):
447 return len(self.data)
448
449
450def test_mapping_abc_contains_must_not_trigger_default_lookup():

Calls

no outgoing calls