]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-140170: Fix test_site with -s flag (GH-140179)
authorStan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
Thu, 16 Oct 2025 09:49:08 +0000 (10:49 +0100)
committerGitHub <noreply@github.com>
Thu, 16 Oct 2025 09:49:08 +0000 (12:49 +0300)
Commit

Lib/test/test_site.py

index 32fcf3162e8efd9f5f7fa42df8c7508691cb4f04..27ae3539b554ef54afb89b924fd8526525b64794 100644 (file)
@@ -855,12 +855,15 @@ class CommandLineTests(unittest.TestCase):
             return 10, None
 
     def invoke_command_line(self, *args):
-        args = ["-m", "site", *args]
+        cmd_args = []
+        if sys.flags.no_user_site:
+            cmd_args.append("-s")
+        cmd_args.extend(["-m", "site", *args])
 
         with EnvironmentVarGuard() as env:
             env["PYTHONUTF8"] = "1"
             env["PYTHONIOENCODING"] = "utf-8"
-            proc = spawn_python(*args, text=True, env=env,
+            proc = spawn_python(*cmd_args, text=True, env=env,
                                 encoding='utf-8', errors='replace')
 
         output = kill_python(proc)