2018-01-01 03:51:19 +00:00
|
|
|
# Copyright 2018 Joshua Bronson. All Rights Reserved.
|
2017-11-20 03:24:08 +00:00
|
|
|
#
|
|
|
|
# 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/.
|
2015-12-21 03:05:20 +00:00
|
|
|
|
2017-11-20 03:24:08 +00:00
|
|
|
Test script for bidict.frozenbidict::
|
|
|
|
|
|
|
|
>>> from bidict import frozenbidict, FrozenOrderedBidict
|
|
|
|
>>> f1 = frozenbidict(one=1)
|
2017-11-16 20:44:51 +00:00
|
|
|
>>> f2 = FrozenOrderedBidict([('one', 1), ('two', 2)])
|
|
|
|
>>> f3 = FrozenOrderedBidict([('two', 2), ('one', 1)])
|
squashed changes for 0.13.0
- support Python 3.6, refactor CI/test setup, increase test coverage
- refactor BidirectionalMapping, BidictBase, OrderedBidictBase,
FrozenBidictBase, and subclasses
- move frozenorderedbidict into _frozen and looseorderedbidict into _loose
- register bidict as a virtual subclass of MutableMapping rather than
inheriting from it directly. This makes it clearer that it does not use any
of the concrete generic methods that MutableMapping provides.
- improve performance and flexibility of frozenbidict and
frozenorderedbidict hashing
- docs, including new type-hierarchy.png diagram
- rm unused imap, ifilter, izip_longest from compat, add PYPY
- update to latest versions of dependencies
- restore benchmarking on travis
2017-01-09 15:37:31 +00:00
|
|
|
>>> fs = (f1, f2, f3)
|
|
|
|
>>> all(hash(f) is not 'an error' for f in fs)
|
|
|
|
True
|
2017-11-29 01:36:39 +00:00
|
|
|
>>> all(hash(f.inv) is not 'an error' for f in fs)
|
|
|
|
True
|
squashed changes for 0.13.0
- support Python 3.6, refactor CI/test setup, increase test coverage
- refactor BidirectionalMapping, BidictBase, OrderedBidictBase,
FrozenBidictBase, and subclasses
- move frozenorderedbidict into _frozen and looseorderedbidict into _loose
- register bidict as a virtual subclass of MutableMapping rather than
inheriting from it directly. This makes it clearer that it does not use any
of the concrete generic methods that MutableMapping provides.
- improve performance and flexibility of frozenbidict and
frozenorderedbidict hashing
- docs, including new type-hierarchy.png diagram
- rm unused imap, ifilter, izip_longest from compat, add PYPY
- update to latest versions of dependencies
- restore benchmarking on travis
2017-01-09 15:37:31 +00:00
|
|
|
|
2017-11-29 01:36:39 +00:00
|
|
|
Hash value is cached for future calls (this shows up in coverage report)::
|
squashed changes for 0.13.0
- support Python 3.6, refactor CI/test setup, increase test coverage
- refactor BidirectionalMapping, BidictBase, OrderedBidictBase,
FrozenBidictBase, and subclasses
- move frozenorderedbidict into _frozen and looseorderedbidict into _loose
- register bidict as a virtual subclass of MutableMapping rather than
inheriting from it directly. This makes it clearer that it does not use any
of the concrete generic methods that MutableMapping provides.
- improve performance and flexibility of frozenbidict and
frozenorderedbidict hashing
- docs, including new type-hierarchy.png diagram
- rm unused imap, ifilter, izip_longest from compat, add PYPY
- update to latest versions of dependencies
- restore benchmarking on travis
2017-01-09 15:37:31 +00:00
|
|
|
|
2018-01-02 21:49:34 +00:00
|
|
|
>>> all(hash(f) for f in fs) # uses cached value, does not have to recompute hash
|
squashed changes for 0.13.0
- support Python 3.6, refactor CI/test setup, increase test coverage
- refactor BidirectionalMapping, BidictBase, OrderedBidictBase,
FrozenBidictBase, and subclasses
- move frozenorderedbidict into _frozen and looseorderedbidict into _loose
- register bidict as a virtual subclass of MutableMapping rather than
inheriting from it directly. This makes it clearer that it does not use any
of the concrete generic methods that MutableMapping provides.
- improve performance and flexibility of frozenbidict and
frozenorderedbidict hashing
- docs, including new type-hierarchy.png diagram
- rm unused imap, ifilter, izip_longest from compat, add PYPY
- update to latest versions of dependencies
- restore benchmarking on travis
2017-01-09 15:37:31 +00:00
|
|
|
True
|
|
|
|
|
|
|
|
Insertable into sets and dicts::
|
|
|
|
|
2017-11-29 01:36:39 +00:00
|
|
|
>>> set(fs) is not 'an error'
|
|
|
|
True
|
|
|
|
>>> dict.fromkeys(fs) is not 'an error'
|
|
|
|
True
|
|
|
|
>>> set(f.inv for f in fs) is not 'an error'
|
|
|
|
True
|
|
|
|
>>> dict.fromkeys(f.inv for f in fs) is not 'an error'
|
squashed changes for 0.13.0
- support Python 3.6, refactor CI/test setup, increase test coverage
- refactor BidirectionalMapping, BidictBase, OrderedBidictBase,
FrozenBidictBase, and subclasses
- move frozenorderedbidict into _frozen and looseorderedbidict into _loose
- register bidict as a virtual subclass of MutableMapping rather than
inheriting from it directly. This makes it clearer that it does not use any
of the concrete generic methods that MutableMapping provides.
- improve performance and flexibility of frozenbidict and
frozenorderedbidict hashing
- docs, including new type-hierarchy.png diagram
- rm unused imap, ifilter, izip_longest from compat, add PYPY
- update to latest versions of dependencies
- restore benchmarking on travis
2017-01-09 15:37:31 +00:00
|
|
|
True
|