Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_prep_str_murmur3_128bit(self):
obj = "a"
expected_result = {
obj: 119173504597196970070553896747624927922
}
result = DeepHash(obj, ignore_string_type_changes=True, hasher=DeepHash.murmur3_128bit)
assert expected_result == result
def test_prep_str_murmur3_64bit(self):
obj = "a"
expected_result = {
obj: 424475663186367154
}
result = DeepHash(obj, ignore_string_type_changes=True, hasher=DeepHash.murmur3_64bit)
assert expected_result == result
def assert_same(thing1, thing2):
"""
Compares two things. Debug logs the differences between them before
asserting that they are the same.
"""
assert cmp(thing1, thing2) == 0, \
"Items are not the same. Difference is:\n %s" % \
pformat(DeepDiff(thing1, thing2), indent=2)
def test_negative_significant_digits(self):
with self.assertRaises(ValueError):
DeepDiff(1, 1, significant_digits=-1)
def test_nested_list_with_dictionarry_difference_ignore_order(self):
t1 = [1, 2, [3, 4, {1: 2}]]
t2 = [[4, 3, {1: 2}], 2, 1]
ddiff = DeepDiff(t1, t2, ignore_order=True)
result = {}
assert result == ddiff
def test_type_change_numeric_when_ignore_order(self, t1, t2, expected_result):
ddiff = DeepDiff(t1, t2, ignore_order=True, ignore_numeric_type_changes=True, ignore_string_type_changes=True)
assert expected_result == ddiff
fields=[
ParsedField(name='title', type='str', nullable=False),
ParsedField(name='director', type='str', nullable=False),
]
)
]
)
]
)
]
))
parsed_dict = asdict(parsed)
assert bool(parsed)
assert parsed_dict == expected, str(DeepDiff(parsed_dict, expected))
def test_same_objects(self):
t1 = {1: 1, 2: 2, 3: 3}
t2 = t1
ddiff = DeepDiff(t1, t2)
res = ddiff.tree
self.assertEqual(res, {})
def test_same_dict_in_list_same_hash(self):
t1 = [{'b': 5, 'c': 4}]
t2 = [{'b': 5, 'c': 4}]
hash1 = DeepHash(t1, view='tree')
hash2 = DeepHash(t2, view='tree')
self.assertEqual(hash1["hash"].hash(), hash2["hash"].hash())
def test_same_dict_same_hash(self):
t1 = {'b': 5, 'c': 4}
t2 = {'b': 5, 'c': 4}
hash1 = DeepHash(t1, view='tree', hasher=sha1)
hash2 = DeepHash(t2, view='tree', hasher=sha1)
self.assertEqual(hash1["hash"].hash(), hash2["hash"].hash())