summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_posix.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2017-06-25 04:33:01 (GMT)
committerGitHub <noreply@github.com>2017-06-25 04:33:01 (GMT)
commit77703942c5997dff00c48f10df1b29b11645624c (patch)
tree58481f08535f9be849539c70bcdce3192a9fcbfa /Lib/test/test_posix.py
parent1ba9469e9fdff0c52ba19b1e13a9c4b7235fc9eb (diff)
downloadcpython-77703942c5997dff00c48f10df1b29b11645624c.zip
cpython-77703942c5997dff00c48f10df1b29b11645624c.tar.gz
cpython-77703942c5997dff00c48f10df1b29b11645624c.tar.bz2
bpo-30746: Prohibited the '=' character in environment variable names (#2382)
in `os.putenv()` and `os.spawn*()`.
Diffstat (limited to 'Lib/test/test_posix.py')
-rw-r--r--Lib/test/test_posix.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/Lib/test/test_posix.py b/Lib/test/test_posix.py
index 412b079..aa1b0e4 100644
--- a/Lib/test/test_posix.py
+++ b/Lib/test/test_posix.py
@@ -813,6 +813,21 @@ class PosixTester(unittest.TestCase):
self.assertEqual(type(k), item_type)
self.assertEqual(type(v), item_type)
+ @unittest.skipUnless(hasattr(os, "putenv"), "requires os.putenv()")
+ def test_putenv(self):
+ with self.assertRaises(ValueError):
+ os.putenv('FRUIT\0VEGETABLE', 'cabbage')
+ with self.assertRaises(ValueError):
+ os.putenv(b'FRUIT\0VEGETABLE', b'cabbage')
+ with self.assertRaises(ValueError):
+ os.putenv('FRUIT', 'orange\0VEGETABLE=cabbage')
+ with self.assertRaises(ValueError):
+ os.putenv(b'FRUIT', b'orange\0VEGETABLE=cabbage')
+ with self.assertRaises(ValueError):
+ os.putenv('FRUIT=ORANGE', 'lemon')
+ with self.assertRaises(ValueError):
+ os.putenv(b'FRUIT=ORANGE', b'lemon')
+
@unittest.skipUnless(hasattr(posix, 'getcwd'), 'test needs posix.getcwd()')
def test_getcwd_long_pathnames(self):
dirname = 'getcwd-test-directory-0123456789abcdef-01234567890abcdef'