Python os.supports_bytes_environ() Examples
The following are 9
code examples of os.supports_bytes_environ().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
os
, or try the search function
.
Example #1
Source File: test_os.py From Fluid-Designer with GNU General Public License v3.0 | 5 votes |
def setUp(self): self.__save = dict(os.environ) if os.supports_bytes_environ: self.__saveb = dict(os.environb) for key, value in self._reference().items(): os.environ[key] = value
Example #2
Source File: test_os.py From Fluid-Designer with GNU General Public License v3.0 | 5 votes |
def tearDown(self): os.environ.clear() os.environ.update(self.__save) if os.supports_bytes_environ: os.environb.clear() os.environb.update(self.__saveb)
Example #3
Source File: test_os.py From Fluid-Designer with GNU General Public License v3.0 | 5 votes |
def test_get_exec_path(self): defpath_list = os.defpath.split(os.pathsep) test_path = ['/monty', '/python', '', '/flying/circus'] test_env = {'PATH': os.pathsep.join(test_path)} saved_environ = os.environ try: os.environ = dict(test_env) # Test that defaulting to os.environ works. self.assertSequenceEqual(test_path, os.get_exec_path()) self.assertSequenceEqual(test_path, os.get_exec_path(env=None)) finally: os.environ = saved_environ # No PATH environment variable self.assertSequenceEqual(defpath_list, os.get_exec_path({})) # Empty PATH environment variable self.assertSequenceEqual(('',), os.get_exec_path({'PATH':''})) # Supplied PATH environment variable self.assertSequenceEqual(test_path, os.get_exec_path(test_env)) if os.supports_bytes_environ: # env cannot contain 'PATH' and b'PATH' keys try: # ignore BytesWarning warning with warnings.catch_warnings(record=True): mixed_env = {'PATH': '1', b'PATH': b'2'} except BytesWarning: # mixed_env cannot be created with python -bb 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'}), ['abc']) self.assertSequenceEqual(os.get_exec_path({b'PATH': 'abc'}), ['abc']) self.assertSequenceEqual(os.get_exec_path({'PATH': b'abc'}), ['abc'])
Example #4
Source File: test_os.py From ironpython3 with Apache License 2.0 | 5 votes |
def setUp(self): self.__save = dict(os.environ) if os.supports_bytes_environ: self.__saveb = dict(os.environb) for key, value in self._reference().items(): os.environ[key] = value
Example #5
Source File: test_os.py From ironpython3 with Apache License 2.0 | 5 votes |
def tearDown(self): os.environ.clear() os.environ.update(self.__save) if os.supports_bytes_environ: os.environb.clear() os.environb.update(self.__saveb)
Example #6
Source File: test_os.py From ironpython3 with Apache License 2.0 | 5 votes |
def test_get_exec_path(self): defpath_list = os.defpath.split(os.pathsep) test_path = ['/monty', '/python', '', '/flying/circus'] test_env = {'PATH': os.pathsep.join(test_path)} saved_environ = os.environ try: os.environ = dict(test_env) # Test that defaulting to os.environ works. self.assertSequenceEqual(test_path, os.get_exec_path()) self.assertSequenceEqual(test_path, os.get_exec_path(env=None)) finally: os.environ = saved_environ # No PATH environment variable self.assertSequenceEqual(defpath_list, os.get_exec_path({})) # Empty PATH environment variable self.assertSequenceEqual(('',), os.get_exec_path({'PATH':''})) # Supplied PATH environment variable self.assertSequenceEqual(test_path, os.get_exec_path(test_env)) if os.supports_bytes_environ: # env cannot contain 'PATH' and b'PATH' keys try: # ignore BytesWarning warning with warnings.catch_warnings(record=True): mixed_env = {'PATH': '1', b'PATH': b'2'} except BytesWarning: # mixed_env cannot be created with python -bb 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'}), ['abc']) self.assertSequenceEqual(os.get_exec_path({b'PATH': 'abc'}), ['abc']) self.assertSequenceEqual(os.get_exec_path({'PATH': b'abc'}), ['abc'])
Example #7
Source File: test_os.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
def setUp(self): self.__save = dict(os.environ) if os.supports_bytes_environ: self.__saveb = dict(os.environb) for key, value in self._reference().items(): os.environ[key] = value
Example #8
Source File: test_os.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
def tearDown(self): os.environ.clear() os.environ.update(self.__save) if os.supports_bytes_environ: os.environb.clear() os.environb.update(self.__saveb)
Example #9
Source File: test_os.py From Project-New-Reign---Nemesis-Main with GNU General Public License v3.0 | 5 votes |
def test_get_exec_path(self): defpath_list = os.defpath.split(os.pathsep) test_path = ['/monty', '/python', '', '/flying/circus'] test_env = {'PATH': os.pathsep.join(test_path)} saved_environ = os.environ try: os.environ = dict(test_env) # Test that defaulting to os.environ works. self.assertSequenceEqual(test_path, os.get_exec_path()) self.assertSequenceEqual(test_path, os.get_exec_path(env=None)) finally: os.environ = saved_environ # No PATH environment variable self.assertSequenceEqual(defpath_list, os.get_exec_path({})) # Empty PATH environment variable self.assertSequenceEqual(('',), os.get_exec_path({'PATH':''})) # Supplied PATH environment variable self.assertSequenceEqual(test_path, os.get_exec_path(test_env)) if os.supports_bytes_environ: # env cannot contain 'PATH' and b'PATH' keys try: # ignore BytesWarning warning with warnings.catch_warnings(record=True): mixed_env = {'PATH': '1', b'PATH': b'2'} except BytesWarning: # mixed_env cannot be created with python -bb 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'}), ['abc']) self.assertSequenceEqual(os.get_exec_path({b'PATH': 'abc'}), ['abc']) self.assertSequenceEqual(os.get_exec_path({'PATH': b'abc'}), ['abc'])