MCPcopy Index your code
hub / github.com/python/cpython / get_hash

Method get_hash

Lib/test/test_hash.py:177–189  ·  view source on GitHub ↗
(self, repr_, seed=None)

Source from the content-addressed store, hash-verified

175 return 'print(hash(eval(%a)))' % repr_
176
177 def get_hash(self, repr_, seed=None):
178 env = os.environ.copy()
179 env['__cleanenv'] = True # signal to assert_python not to do a copy
180 # of os.environ on its own
181 if seed is not None:
182 env['PYTHONHASHSEED'] = str(seed)
183 else:
184 env.pop('PYTHONHASHSEED', None)
185 out = assert_python_ok(
186 '-c', self.get_hash_command(repr_),
187 **env)
188 stdout = out[1].strip()
189 return int(stdout)
190
191 def test_randomized_hash(self):
192 # two runs should return different hashes

Callers 5

test_randomized_hashMethod · 0.95
test_null_hashMethod · 0.80
test_fixed_hashMethod · 0.80
test_long_fixed_hashMethod · 0.80
test_ucs2_stringMethod · 0.80

Calls 6

get_hash_commandMethod · 0.95
assert_python_okFunction · 0.90
strFunction · 0.85
copyMethod · 0.45
popMethod · 0.45
stripMethod · 0.45

Tested by

no test coverage detected