fix pexpect-3.0 compatibility for pytest's own tests.

(fixes issue386)
This commit is contained in:
holger krekel 2013-11-19 10:10:27 +01:00
parent 97252a8b66
commit 1fd1617427
4 changed files with 15 additions and 16 deletions

View File

@ -1,6 +1,9 @@
Unreleased
-----------------------------------
- fix pexpect-3.0 compatibility for pytest's own tests.
(fixes issue386)
- allow nested parametrize-value markers, thanks James Lan for the PR.
- fix unicode handling with new monkeypatch.setattr(import_path, value)

View File

@ -516,15 +516,16 @@ class TmpTestdir:
return self.spawn(cmd, expect_timeout=expect_timeout)
def spawn(self, cmd, expect_timeout=10.0):
pexpect = py.test.importorskip("pexpect", "2.4")
pexpect = py.test.importorskip("pexpect", "3.0")
if hasattr(sys, 'pypy_version_info') and '64' in py.std.platform.machine():
pytest.skip("pypy-64 bit not supported")
if sys.platform == "darwin":
pytest.xfail("pexpect does not work reliably on darwin?!")
if sys.platform.startswith("freebsd"):
pytest.xfail("pexpect does not work reliably on freebsd")
logfile = self.tmpdir.join("spawn.out")
child = pexpect.spawn(cmd, logfile=logfile.open("w"))
logfile = self.tmpdir.join("spawn.out").open("wb")
child = pexpect.spawn(cmd, logfile=logfile)
self.request.addfinalizer(logfile.close)
child.timeout = expect_timeout
return child

View File

@ -1,3 +1,4 @@
import py
import sys
@ -62,7 +63,7 @@ class TestPDB:
child.expect(".*i = 0")
child.expect("(Pdb)")
child.sendeof()
rest = child.read()
rest = child.read().decode("utf8")
assert "1 failed" in rest
assert "def test_1" not in rest
if child.isalive():
@ -127,7 +128,7 @@ class TestPDB:
child.expect("x = 3")
child.expect("(Pdb)")
child.sendeof()
rest = child.read()
rest = child.read().decode("utf-8")
assert "1 failed" in rest
assert "def test_1" in rest
assert "hello17" in rest # out is captured
@ -144,7 +145,7 @@ class TestPDB:
child.expect("test_1")
child.expect("(Pdb)")
child.sendeof()
rest = child.read()
rest = child.read().decode("utf8")
assert "1 failed" in rest
assert "reading from stdin while output" not in rest
if child.isalive():
@ -182,7 +183,7 @@ class TestPDB:
child.expect("0")
child.expect("(Pdb)")
child.sendeof()
rest = child.read()
rest = child.read().decode("utf8")
assert "1 failed" in rest
if child.isalive():
child.wait()
@ -206,7 +207,7 @@ class TestPDB:
child.sendline('c')
child.expect("x = 4")
child.sendeof()
rest = child.read()
rest = child.read().decode("utf8")
assert "1 failed" in rest
assert "def test_1" in rest
assert "hello17" in rest # out is captured
@ -238,6 +239,7 @@ class TestPDB:
child.expect("x = 5")
child.sendeof()
child.wait()
def test_pdb_collection_failure_is_shown(self, testdir):
p1 = testdir.makepyfile("""xxx """)
result = testdir.runpytest("--pdb", p1)

View File

@ -16,6 +16,7 @@ commands= py.test --genscript=pytest1
[testenv:py25]
setenv =
PIP_INSECURE=1
deps=nose
[testenv:flakes]
changedir=
@ -55,14 +56,6 @@ changedir=.
commands=py.test --doctest-modules _pytest
deps=
[testenv:py32]
deps=
nose
[testenv:py33]
deps=
nose
[testenv:doc]
basepython=python
changedir=doc/en