diff options
author | Victor Stinner <victor.stinner@haypocalc.com> | 2010-08-19 17:10:18 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@haypocalc.com> | 2010-08-19 17:10:18 (GMT) |
commit | 38430e2dffa3fd9d1648681f3b705917631bdc9a (patch) | |
tree | 29e3b4d324aae125d5468a0eb17253d1e9dc5363 /Lib/test/test_os.py | |
parent | 9802b39c12712e924bed699812756ce5076b77a3 (diff) | |
download | cpython-38430e2dffa3fd9d1648681f3b705917631bdc9a.zip cpython-38430e2dffa3fd9d1648681f3b705917631bdc9a.tar.gz cpython-38430e2dffa3fd9d1648681f3b705917631bdc9a.tar.bz2 |
Fix os.get_exec_path() (code and tests) for python -bb
Catch BytesWarning exceptions.
Diffstat (limited to 'Lib/test/test_os.py')
-rw-r--r-- | Lib/test/test_os.py | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/Lib/test/test_os.py b/Lib/test/test_os.py index 4910b1e..710a3f4 100644 --- a/Lib/test/test_os.py +++ b/Lib/test/test_os.py @@ -450,8 +450,12 @@ class EnvironTests(mapping_tests.BasicTestMappingProtocol): if os.supports_bytes_environ: # env cannot contain 'PATH' and b'PATH' keys - self.assertRaises(ValueError, - os.get_exec_path, {'PATH': '1', b'PATH': b'2'}) + try: + mixed_env = {'PATH': '1', b'PATH': b'2'} + except BytesWarning: + pass + else: + self.assertRaises(ValueError, os.get_exec_path, mixed_env) # bytes key and/or value self.assertSequenceEqual(os.get_exec_path({b'PATH': b'abc'}), @@ -723,7 +727,10 @@ class ExecTests(unittest.TestCase): # os.get_exec_path() reads the 'PATH' variable with _execvpe_mockup() as calls: env_path = env.copy() - env_path['PATH'] = program_path + if test_type is bytes: + env_path[b'PATH'] = program_path + else: + env_path['PATH'] = program_path self.assertRaises(OSError, os._execvpe, program, arguments, env=env_path) self.assertEqual(len(calls), 1) |