File tree Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -40,6 +40,8 @@ def dict_hash(obj, start=''):
4040 value = str (obj )
4141 elif isinstance (obj , (six .text_type , bytes )):
4242 value = obj
43+ elif obj is None :
44+ value = b''
4345 else :
4446 raise ValueError ("Unsupported value type: %s" % obj .__class__ )
4547 h .update (to_bytes (value ))
Original file line number Diff line number Diff line change 55from hypothesis import given , assume
66from hypothesis import strategies as st
77from scrapy .http import Headers
8- from scrapy_splash .utils import headers_to_scrapy , _fast_hash , json_based_hash
8+ from scrapy_splash .utils import (
9+ headers_to_scrapy ,
10+ _fast_hash ,
11+ json_based_hash ,
12+ dict_hash
13+ )
914
1015
1116def test_headers_to_scrapy ():
@@ -56,6 +61,13 @@ def _dump(v):
5661 assert _fast_hash (val1 ) != _fast_hash (val2 )
5762
5863
64+ @given (_data , _data )
65+ def test_dict_hash (val1 , val2 ):
66+ assume (val1 != val2 )
67+ assert dict_hash (val1 ) == dict_hash (val1 )
68+ assert dict_hash (val1 ) != dict_hash (val2 )
69+
70+
5971@given (_data_notuples , _data_notuples )
6072def test_json_based_hash (val1 , val2 ):
6173 assume (val1 != val2 )
You can’t perform that action at this time.
0 commit comments