forked from cool-RR/python_toolbox
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_cheat_hashing.py
More file actions
33 lines (25 loc) · 790 Bytes
/
test_cheat_hashing.py
File metadata and controls
33 lines (25 loc) · 790 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# Copyright 2009-2017 Ram Rachum.
# This program is distributed under the MIT license.
'''Testing module for `python_toolbox.abc_tools.AbstractStaticMethod`.'''
import copy
from python_toolbox.cheat_hashing import cheat_hash
def test_cheat_hash():
'''Test `cheat_hash` on various objects.'''
things = [
1,
7,
4.5,
[1, 2, 3.4],
(1, 2, 3.4),
{1: 2, 3: 4.5},
{1, 2, 3.4},
[1, [1, 2], 3],
[1, {frozenset((1, 2)): 'meow'}, 3],
sum,
None,
(None, {None: None})
]
things_copy = copy.deepcopy(things)
for thing, thing_copy in zip(things, things_copy):
assert cheat_hash(thing) == cheat_hash(thing) == \
cheat_hash(thing_copy) == cheat_hash(thing_copy)