windows fixes and print funcargs for keyboardinterrupt traces

--HG--
branch : trunk
This commit is contained in:
holger krekel 2009-12-25 09:53:36 +01:00
parent d28838bbb6
commit 516cee2a94
4 changed files with 13 additions and 3 deletions

View File

@ -66,7 +66,10 @@ class VirtualEnv(object):
return "<VirtualEnv at %r>" %(self.path)
def _cmd(self, name):
return os.path.join(self.path, 'bin', name)
if sys.platform == "win32":
return os.path.join(self.path, 'Scripts', name)
else:
return os.path.join(self.path, 'bin', name)
def ensure(self):
if not os.path.exists(self._cmd('python')):

View File

@ -14,7 +14,9 @@ def cmdexec(cmd):
the exception will provide an 'err' attribute containing
the error-output from the command.
"""
process = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
process = subprocess.Popen(cmd, shell=True,
universal_newlines=True,
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
out, err = process.communicate()
out = py.builtin._totext(out, sys.getdefaultencoding())
err = py.builtin._totext(err, sys.getdefaultencoding())

View File

@ -292,7 +292,7 @@ class TerminalReporter:
self.summary_stats()
def pytest_keyboard_interrupt(self, excinfo):
self._keyboardinterrupt_memo = excinfo.getrepr()
self._keyboardinterrupt_memo = excinfo.getrepr(funcargs=True)
def _report_keyboardinterrupt(self):
self.write_sep("!", "KEYBOARD INTERRUPT")

View File

@ -9,6 +9,11 @@ class Test_exec_cmd:
out = cmdexec('echo hallo')
assert out.strip() == 'hallo'
def test_simple_newline(self):
import sys
out = cmdexec(r"""%s -c "print ('hello')" """ % sys.executable)
assert out == 'hello\n'
def test_simple_error(self):
py.test.raises (cmdexec.Error, cmdexec, 'exit 1')