bidict/tests/test_loosebidict.txt

33 lines
704 B
Plaintext
Raw Normal View History

Test script for bidict.loosebidict::
>>> from bidict import loosebidict
Initializing with different keys mapping to the same value succeeds::
>>> loosebidict([(1, 1), (2, 1)])
loosebidict({2: 1})
Adding a new key associated with an existing value succeeds::
>>> b = loosebidict({1: 1})
>>> b[2] = 1
>>> b
loosebidict({2: 1})
>>> b.update({3: 1})
>>> b
loosebidict({3: 1})
2016-06-28 04:05:22 +00:00
Using ``update`` with an existing key successfully overwrites::
2016-06-28 04:05:22 +00:00
>>> b.update({3: 2})
>>> b
2016-06-28 04:05:22 +00:00
loosebidict({3: 2})
Subclassing works as expected::
>>> class myloosebidict(loosebidict): pass
>>> b = myloosebidict()
>>> b[2] = 4
>>> b
2016-06-28 04:05:22 +00:00
myloosebidict({2: 4})