def test_insert(d): key = rand_string() value = rand_string() d[key] = value assert key in d assert super(PrehashedDict, d).__contains__(sha1_fn(key)) assert d[key] == value assert super(PrehashedDict, d).__getitem__(sha1_fn(key))
def find(needles, haystack, hash_me=True): found = True for k, v in needles: if hash_me: k = sha1_fn(k) found_me = False for h in haystack: if h[0] == k and h[1] == v: found_me = True found = found_me return found
def test_sha1_obj_value(class_ex): gold = 633327772932199023258151861061014836005222876887 assert sha1_fn(class_ex) == gold
def test_sha1_obj_type(class_ex): assert isinstance(sha1_fn(class_ex), int)
def test_sha1_int_value(): key = 1 gold = 304942582444936629325699363757435820077590259883 assert sha1_fn(key) == gold
def test_sha1_int_type(): key = random.randint(2, 101) assert isinstance(sha1_fn(key), int)
def test_sha1_value(): key = 'test' gold = 966482230667555116936258103322711973649032657875 assert sha1_fn(key) == gold
def test_sha1_type(): key = rand_string() assert isinstance(sha1_fn(key), int)