Commits

Ned Batchelder committed 0aeb5b6

Can't just run 'python' in a subprocess from 3.x, since it doesn't install as 'python'.

  • Participants
  • Parent commits d7a4311

Comments (0)

Files changed (2)

tests/coveragetest.py

         Returns the process' stdout text.
 
         """
+        # Running Python subprocesses can be tricky.  Use the real name of our
+        # own executable.  So "python foo.py" might get executed as
+        # "python3.3 foo.py".  This is important because Python 3.x doesn't
+        # install as "python", so you might get a Python 2 executable instead
+        # if you don't use the executable's basename.
+        if cmd.startswith("python "):
+            cmd = os.path.basename(sys.executable) + cmd[6:]
+
         _, output = self.run_command_status(cmd)
         return output
 

tests/test_process.py

             raise SkipTest(
                 "Can't test subprocess pth file suppport during metacoverage"
                 )
+
         # Main will run sub.py
         self.make_file("main.py", """\
-            import os
-            os.system("python sub.py")
+            import os, os.path, sys
+            ex = os.path.basename(sys.executable)
+            os.system(ex + " sub.py")
             """)
         # sub.py will write a few lines.
         self.make_file("sub.py", """\