Skip to content

Commit 3159919

Browse files
committed
Add test
1 parent 23999d9 commit 3159919

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

Lib/test/test_readline.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@
33
"""
44
import locale
55
import os
6+
import subprocess
67
import sys
78
import tempfile
89
import textwrap
910
import threading
1011
import unittest
1112
from test import support
13+
from test.support import requires_subprocess
1214
from test.support import threading_helper
1315
from test.support import verbose
1416
from test.support.import_helper import import_module
@@ -405,6 +407,17 @@ def test_write_read_limited_history(self):
405407
# So, we've only tested that the read did not fail.
406408
# See TestHistoryManipulation for the full test.
407409

410+
@requires_subprocess()
411+
def test_environment_is_not_modified(self):
412+
env_output = subprocess.check_output(["env"])
413+
env_lines = env_output.decode('utf-8', 'surrogateescape').splitlines()
414+
current_env = dict([line.split('=', 1) for line in env_lines])
415+
416+
changes = {k for k in set(os.environ).union(current_env)
417+
if os.getenv(k) != current_env.get(k)}
418+
419+
self.assertEqual(len(changes), 0)
420+
408421

409422
@unittest.skipUnless(support.Py_GIL_DISABLED, 'these tests can only possibly fail with GIL disabled')
410423
class FreeThreadingTest(unittest.TestCase):

0 commit comments

Comments
 (0)