fix pexpect-3.0 compatibility for pytest's own tests.
(fixes issue386)
This commit is contained in:
parent
97252a8b66
commit
1fd1617427
|
@ -1,6 +1,9 @@
|
||||||
Unreleased
|
Unreleased
|
||||||
-----------------------------------
|
-----------------------------------
|
||||||
|
|
||||||
|
- fix pexpect-3.0 compatibility for pytest's own tests.
|
||||||
|
(fixes issue386)
|
||||||
|
|
||||||
- allow nested parametrize-value markers, thanks James Lan for the PR.
|
- allow nested parametrize-value markers, thanks James Lan for the PR.
|
||||||
|
|
||||||
- fix unicode handling with new monkeypatch.setattr(import_path, value)
|
- fix unicode handling with new monkeypatch.setattr(import_path, value)
|
||||||
|
|
|
@ -516,15 +516,16 @@ class TmpTestdir:
|
||||||
return self.spawn(cmd, expect_timeout=expect_timeout)
|
return self.spawn(cmd, expect_timeout=expect_timeout)
|
||||||
|
|
||||||
def spawn(self, cmd, expect_timeout=10.0):
|
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():
|
if hasattr(sys, 'pypy_version_info') and '64' in py.std.platform.machine():
|
||||||
pytest.skip("pypy-64 bit not supported")
|
pytest.skip("pypy-64 bit not supported")
|
||||||
if sys.platform == "darwin":
|
if sys.platform == "darwin":
|
||||||
pytest.xfail("pexpect does not work reliably on darwin?!")
|
pytest.xfail("pexpect does not work reliably on darwin?!")
|
||||||
if sys.platform.startswith("freebsd"):
|
if sys.platform.startswith("freebsd"):
|
||||||
pytest.xfail("pexpect does not work reliably on freebsd")
|
pytest.xfail("pexpect does not work reliably on freebsd")
|
||||||
logfile = self.tmpdir.join("spawn.out")
|
logfile = self.tmpdir.join("spawn.out").open("wb")
|
||||||
child = pexpect.spawn(cmd, logfile=logfile.open("w"))
|
child = pexpect.spawn(cmd, logfile=logfile)
|
||||||
|
self.request.addfinalizer(logfile.close)
|
||||||
child.timeout = expect_timeout
|
child.timeout = expect_timeout
|
||||||
return child
|
return child
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
|
||||||
import py
|
import py
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
@ -62,7 +63,7 @@ class TestPDB:
|
||||||
child.expect(".*i = 0")
|
child.expect(".*i = 0")
|
||||||
child.expect("(Pdb)")
|
child.expect("(Pdb)")
|
||||||
child.sendeof()
|
child.sendeof()
|
||||||
rest = child.read()
|
rest = child.read().decode("utf8")
|
||||||
assert "1 failed" in rest
|
assert "1 failed" in rest
|
||||||
assert "def test_1" not in rest
|
assert "def test_1" not in rest
|
||||||
if child.isalive():
|
if child.isalive():
|
||||||
|
@ -127,7 +128,7 @@ class TestPDB:
|
||||||
child.expect("x = 3")
|
child.expect("x = 3")
|
||||||
child.expect("(Pdb)")
|
child.expect("(Pdb)")
|
||||||
child.sendeof()
|
child.sendeof()
|
||||||
rest = child.read()
|
rest = child.read().decode("utf-8")
|
||||||
assert "1 failed" in rest
|
assert "1 failed" in rest
|
||||||
assert "def test_1" in rest
|
assert "def test_1" in rest
|
||||||
assert "hello17" in rest # out is captured
|
assert "hello17" in rest # out is captured
|
||||||
|
@ -144,7 +145,7 @@ class TestPDB:
|
||||||
child.expect("test_1")
|
child.expect("test_1")
|
||||||
child.expect("(Pdb)")
|
child.expect("(Pdb)")
|
||||||
child.sendeof()
|
child.sendeof()
|
||||||
rest = child.read()
|
rest = child.read().decode("utf8")
|
||||||
assert "1 failed" in rest
|
assert "1 failed" in rest
|
||||||
assert "reading from stdin while output" not in rest
|
assert "reading from stdin while output" not in rest
|
||||||
if child.isalive():
|
if child.isalive():
|
||||||
|
@ -182,7 +183,7 @@ class TestPDB:
|
||||||
child.expect("0")
|
child.expect("0")
|
||||||
child.expect("(Pdb)")
|
child.expect("(Pdb)")
|
||||||
child.sendeof()
|
child.sendeof()
|
||||||
rest = child.read()
|
rest = child.read().decode("utf8")
|
||||||
assert "1 failed" in rest
|
assert "1 failed" in rest
|
||||||
if child.isalive():
|
if child.isalive():
|
||||||
child.wait()
|
child.wait()
|
||||||
|
@ -206,7 +207,7 @@ class TestPDB:
|
||||||
child.sendline('c')
|
child.sendline('c')
|
||||||
child.expect("x = 4")
|
child.expect("x = 4")
|
||||||
child.sendeof()
|
child.sendeof()
|
||||||
rest = child.read()
|
rest = child.read().decode("utf8")
|
||||||
assert "1 failed" in rest
|
assert "1 failed" in rest
|
||||||
assert "def test_1" in rest
|
assert "def test_1" in rest
|
||||||
assert "hello17" in rest # out is captured
|
assert "hello17" in rest # out is captured
|
||||||
|
@ -238,6 +239,7 @@ class TestPDB:
|
||||||
child.expect("x = 5")
|
child.expect("x = 5")
|
||||||
child.sendeof()
|
child.sendeof()
|
||||||
child.wait()
|
child.wait()
|
||||||
|
|
||||||
def test_pdb_collection_failure_is_shown(self, testdir):
|
def test_pdb_collection_failure_is_shown(self, testdir):
|
||||||
p1 = testdir.makepyfile("""xxx """)
|
p1 = testdir.makepyfile("""xxx """)
|
||||||
result = testdir.runpytest("--pdb", p1)
|
result = testdir.runpytest("--pdb", p1)
|
||||||
|
|
9
tox.ini
9
tox.ini
|
@ -16,6 +16,7 @@ commands= py.test --genscript=pytest1
|
||||||
[testenv:py25]
|
[testenv:py25]
|
||||||
setenv =
|
setenv =
|
||||||
PIP_INSECURE=1
|
PIP_INSECURE=1
|
||||||
|
deps=nose
|
||||||
|
|
||||||
[testenv:flakes]
|
[testenv:flakes]
|
||||||
changedir=
|
changedir=
|
||||||
|
@ -55,14 +56,6 @@ changedir=.
|
||||||
commands=py.test --doctest-modules _pytest
|
commands=py.test --doctest-modules _pytest
|
||||||
deps=
|
deps=
|
||||||
|
|
||||||
[testenv:py32]
|
|
||||||
deps=
|
|
||||||
nose
|
|
||||||
|
|
||||||
[testenv:py33]
|
|
||||||
deps=
|
|
||||||
nose
|
|
||||||
|
|
||||||
[testenv:doc]
|
[testenv:doc]
|
||||||
basepython=python
|
basepython=python
|
||||||
changedir=doc/en
|
changedir=doc/en
|
||||||
|
|
Loading…
Reference in New Issue