bidict/tests/test_frozenbidict.txt

26 lines
851 B
Plaintext
Raw Normal View History

# Copyright 2017 Joshua Bronson. All Rights Reserved.
#
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
Test script for bidict.frozenbidict::
>>> from bidict import frozenbidict, FrozenOrderedBidict
>>> f1 = frozenbidict(one=1)
>>> f2 = FrozenOrderedBidict([('one', 1), ('two', 2)])
>>> f3 = FrozenOrderedBidict([('two', 2), ('one', 1)])
>>> fs = (f1, f2, f3)
>>> all(hash(f) is not 'an error' for f in fs)
True
Cached hash value reused (for the sake of the coverage report)::
>>> all(hash(f) for f in fs) # should not have to call _compute_hash() again
True
Insertable into sets and dicts::
>>> dict.fromkeys(fs) and set(fs) is not 'an error'
True