Skip to content

Commit e170a99

Browse files
committed
Fix tests
1 parent 16218cf commit e170a99

File tree

3 files changed

+22
-23
lines changed

3 files changed

+22
-23
lines changed

Lib/test/test_cmd_line.py

-20
Original file line numberDiff line numberDiff line change
@@ -1008,26 +1008,6 @@ def test_sys_flags_not_set(self):
10081008
PYTHONSAFEPATH="1",
10091009
)
10101010

1011-
# TODO: RUSTPYTHON
1012-
@unittest.expectedFailure
1013-
def test_pythonsafepath_env(self):
1014-
# Test the PYTHONSAFEPATH environment variable
1015-
code = "import sys; print(sys.flags.safe_path)"
1016-
env = dict(os.environ)
1017-
env.pop('PYTHONSAFEPATH', None)
1018-
args = (sys.executable, '-P', code)
1019-
1020-
proc = subprocess.run(args, stdout=subprocess.PIPE,
1021-
universal_newlines=True, env=env)
1022-
self.assertEqual(proc.stdout.rstrip(), 'False')
1023-
self.assertEqual(proc.returncode, 0, proc)
1024-
1025-
env['PYTHONSAFEPATH'] = '1'
1026-
proc = subprocess.run(args, stdout=subprocess.PIPE,
1027-
universal_newlines=True, env=env)
1028-
self.assertEqual(proc.stdout.rstrip(), 'True')
1029-
self.assertEqual(proc.returncode, 0, proc)
1030-
10311011
class SyntaxErrorTests(unittest.TestCase):
10321012
def check_string(self, code):
10331013
proc = subprocess.run([sys.executable, "-"], input=code,

Lib/test/test_support.py

-2
Original file line numberDiff line numberDiff line change
@@ -513,8 +513,6 @@ def check_options(self, args, func, expected=None):
513513
self.assertEqual(proc.stdout.rstrip(), repr(expected))
514514
self.assertEqual(proc.returncode, 0)
515515

516-
# TODO: RUSTPYTHON
517-
# @unittest.expectedFailure
518516
def test_args_from_interpreter_flags(self):
519517
# Test test.support.args_from_interpreter_flags()
520518
for opts in (

extra_tests/snippets/stdlib_sys.py

+22-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import sys
2+
import os
3+
import subprocess
24

35
from testutils import assert_raises
46

@@ -105,4 +107,23 @@ def recursive_call(n):
105107
sys.set_int_max_str_digits(1)
106108

107109
sys.set_int_max_str_digits(1000)
108-
assert sys.get_int_max_str_digits() == 1000
110+
assert sys.get_int_max_str_digits() == 1000
111+
112+
# Test the PYTHONSAFEPATH environment variable
113+
code = "import sys; print(sys.flags.safe_path)"
114+
env = dict(os.environ)
115+
env.pop('PYTHONSAFEPATH', None)
116+
args = (sys.executable, '-P', '-c', code)
117+
118+
proc = subprocess.run(
119+
args, stdout=subprocess.PIPE,
120+
universal_newlines=True, env=env)
121+
assert proc.stdout.rstrip() == 'True', proc
122+
assert proc.returncode == 0, proc
123+
124+
env['PYTHONSAFEPATH'] = '1'
125+
proc = subprocess.run(
126+
args, stdout=subprocess.PIPE,
127+
universal_newlines=True, env=env)
128+
assert proc.stdout.rstrip() == 'True'
129+
assert proc.returncode == 0, proc

0 commit comments

Comments
 (0)