(self, repr_, seed=None)
| 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 |
no test coverage detected