Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitad6553c

Browse files
committed
Add test_pythonsafepath_env in test_cmd_line
1 parentf3e18e9 commitad6553c

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

‎Lib/subprocess.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,7 @@ def _args_from_interpreter_flags():
288288
'verbose':'v',
289289
'bytes_warning':'b',
290290
'quiet':'q',
291+
'safe_path':'P'
291292
# -O is handled in _optim_args_from_interpreter_flags()
292293
}
293294
args=_optim_args_from_interpreter_flags()

‎Lib/test/test_cmd_line.py‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -884,6 +884,25 @@ def test_sys_flags_not_set(self):
884884
PYTHONVERBOSE="1",
885885
)
886886

887+
# TODO: RUSTPYTHON
888+
@unittest.expectedFailure
889+
deftest_pythonsafepath_env(self):
890+
# Test the PYTHONSAFEPATH environment variable
891+
code="import sys; print(sys.flags.safe_path)"
892+
env=dict(os.environ)
893+
env.pop('PYTHONSAFEPATH',None)
894+
args= (sys.executable,'-P',code)
895+
896+
proc=subprocess.run(args,stdout=subprocess.PIPE,
897+
universal_newlines=True,env=env)
898+
self.assertEqual(proc.stdout.rstrip(),'False')
899+
self.assertEqual(proc.returncode,0,proc)
900+
901+
env['PYTHONSAFEPATH']='1'
902+
proc=subprocess.run(args,stdout=subprocess.PIPE,
903+
universal_newlines=True,env=env)
904+
self.assertEqual(proc.stdout.rstrip(),'True')
905+
self.assertEqual(proc.returncode,0,proc)
887906

888907
deftest_main():
889908
support.run_unittest(CmdLineTest,IgnoreEnvironmentTest)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp