diff options
author | Georg Brandl <georg@python.org> | 2012-02-20 23:33:36 (GMT) |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2012-02-20 23:33:36 (GMT) |
commit | 2fb477c0f0284439d40cb3f46eea45ef42446e53 (patch) | |
tree | c8df3747d511256d56ca4af046db7915b5c06096 /Lib/test/test_cmd_line.py | |
parent | b5c793a0b349cb02003433c30a410595b224079f (diff) | |
parent | 9edceb3e591063f382ae82e14313813ffc1af0bf (diff) | |
download | cpython-2fb477c0f0284439d40cb3f46eea45ef42446e53.zip cpython-2fb477c0f0284439d40cb3f46eea45ef42446e53.tar.gz cpython-2fb477c0f0284439d40cb3f46eea45ef42446e53.tar.bz2 |
Merge 3.2: Issue #13703 plus some related test suite fixes.
Diffstat (limited to 'Lib/test/test_cmd_line.py')
-rw-r--r-- | Lib/test/test_cmd_line.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/Lib/test/test_cmd_line.py b/Lib/test/test_cmd_line.py index 70dfb17..01af9b9 100644 --- a/Lib/test/test_cmd_line.py +++ b/Lib/test/test_cmd_line.py @@ -324,6 +324,22 @@ class CmdLineTest(unittest.TestCase): def test_no_std_streams(self): self._test_no_stdio(['stdin', 'stdout', 'stderr']) + def test_hash_randomization(self): + # Verify that -R enables hash randomization: + self.verify_valid_flag('-R') + hashes = [] + for i in range(2): + code = 'print(hash("spam"))' + rc, out, err = assert_python_ok('-R', '-c', code) + self.assertEqual(rc, 0) + hashes.append(out) + self.assertNotEqual(hashes[0], hashes[1]) + + # Verify that sys.flags contains hash_randomization + code = 'import sys; print("random is", sys.flags.hash_randomization)' + rc, out, err = assert_python_ok('-R', '-c', code) + self.assertEqual(rc, 0) + self.assertIn(b'random is 1', out) def test_main(): test.support.run_unittest(CmdLineTest) |