holger krekel avatar holger krekel committed 953896b

only use shell=True on Windows and test for it, also streamlining a test

Comments (0)

Files changed (3)


             (cat, messagepattern, self._index+1, self._calls))
 class pcallMock:
-    def __init__(self, args, cwd, env, stdout, stderr):
+    def __init__(self, args, cwd, env, stdout, stderr, shell):
         self.args = args
         self.cwd = cwd
         self.env = env
         self.stdout = stdout
         self.stderr = stderr
+        self.shell = shell
     def communicate(self):
         return "", ""
             self.report = ReportExpectMock(self)
         def make_emptydir(self, path):
-        def popen(self, args, cwd, shell=True, stdout=None, stderr=None, 
-		env=None):
-            pm = pcallMock(args, cwd, env, stdout, stderr)
+        def popen(self, args, cwd, shell=None,
+            stdout=None, stderr=None, env=None):
+            pm = pcallMock(args, cwd, env, stdout, stderr, shell)
             return pm
     return MockSession()


 import tox
 import py
 import pytest
+import sys
 from conftest import ReportExpectMock
 pytest_plugins = "pytester"
         assert sdist_share.check()
         assert sdist_share.read("rb") == sdist.read("rb"), (sdist_share, sdist)
-    def test_log_pcall(self, initproj, tmpdir):
-        initproj("logexample123-0.5", filedefs={
-            'tests': {'test_hello.py': "def test_hello(): pass"},
-            'tox.ini': '''
-            '''
-        })
-        config = parseconfig([])
-        session = Session(config, Report=ReportExpectMock)
-        assert session.report.session == session
-        assert not session.config.logdir.listdir()
-        action = session.newaction(None, "something")
+    def test_log_pcall(self, mocksession):
+        mocksession.config.logdir.ensure(dir=1)
+        assert not mocksession.config.logdir.listdir()
+        action = mocksession.newaction(None, "something")
         action.popen(["echo", ])
-        match = session.report.getnext("logpopen")
-        assert match[1].outpath.relto(session.config.logdir)
+        match = mocksession.report.getnext("logpopen")
+        assert match[1].outpath.relto(mocksession.config.logdir)
+        assert match[1].shell == (sys.platform == "win32")
     def test_summary_status(self, initproj, capfd):
         initproj("logexample123-0.5", filedefs={
         #args = [str(x) for x in args]
         if env is None:
             env = os.environ.copy()
-        return self.session.popen(args, cwd=str(cwd), shell=True,
-	    stdout=stdout, stderr=stderr, env=env)
+        shell = (sys.platform == "win32")
+        return self.session.popen(args, shell=shell, cwd=str(cwd),
+	        stdout=stdout, stderr=stderr, env=env)
 class Reporter:
     actionchar = "-"
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.