Skip to content

Commit

Permalink
Merge pull request #2024 from jaraco/issue-2022
Browse files Browse the repository at this point in the history
Restore pexpect tests on macOS. Fixes #2022.
  • Loading branch information
nicoddemus committed Oct 21, 2016
2 parents 82fb63c + f2c01c5 commit 7f95ea3
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 28 deletions.
2 changes: 0 additions & 2 deletions _pytest/pytester.py
Expand Up @@ -1002,8 +1002,6 @@ def spawn(self, cmd, expect_timeout=10.0):
pexpect = pytest.importorskip("pexpect", "3.0")
if hasattr(sys, 'pypy_version_info') and '64' in 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").open("wb")
Expand Down
47 changes: 21 additions & 26 deletions testing/test_pdb.py
@@ -1,4 +1,5 @@
import sys
import platform

import _pytest._code
import pytest
Expand Down Expand Up @@ -76,6 +77,12 @@ def test_1():
rest = child.read().decode("utf8")
assert "1 failed" in rest
assert "def test_1" not in rest
self.flush(child)

@staticmethod
def flush(child):
if platform.system() == 'Darwin':
return
if child.isalive():
child.wait()

Expand All @@ -95,8 +102,7 @@ def test_false(self):
child.sendeof()
rest = child.read().decode("utf8")
assert 'debug.me' in rest
if child.isalive():
child.wait()
self.flush(child)

def test_pdb_interaction_capture(self, testdir):
p1 = testdir.makepyfile("""
Expand All @@ -111,8 +117,7 @@ def test_1():
rest = child.read().decode("utf8")
assert "1 failed" in rest
assert "getrekt" not in rest
if child.isalive():
child.wait()
self.flush(child)

def test_pdb_interaction_exception(self, testdir):
p1 = testdir.makepyfile("""
Expand All @@ -130,8 +135,7 @@ def test_1():
child.expect(".*function")
child.sendeof()
child.expect("1 failed")
if child.isalive():
child.wait()
self.flush(child)

def test_pdb_interaction_on_collection_issue181(self, testdir):
p1 = testdir.makepyfile("""
Expand All @@ -143,8 +147,7 @@ def test_pdb_interaction_on_collection_issue181(self, testdir):
child.expect("(Pdb)")
child.sendeof()
child.expect("1 error")
if child.isalive():
child.wait()
self.flush(child)

def test_pdb_interaction_on_internal_error(self, testdir):
testdir.makeconftest("""
Expand All @@ -156,8 +159,7 @@ def pytest_runtest_protocol():
#child.expect(".*import pytest.*")
child.expect("(Pdb)")
child.sendeof()
if child.isalive():
child.wait()
self.flush(child)

def test_pdb_interaction_capturing_simple(self, testdir):
p1 = testdir.makepyfile("""
Expand All @@ -177,8 +179,7 @@ def test_1():
assert "1 failed" in rest
assert "def test_1" in rest
assert "hello17" in rest # out is captured
if child.isalive():
child.wait()
self.flush(child)

def test_pdb_set_trace_interception(self, testdir):
p1 = testdir.makepyfile("""
Expand All @@ -193,8 +194,7 @@ def test_1():
rest = child.read().decode("utf8")
assert "1 failed" in rest
assert "reading from stdin while output" not in rest
if child.isalive():
child.wait()
self.flush(child)

def test_pdb_and_capsys(self, testdir):
p1 = testdir.makepyfile("""
Expand All @@ -209,8 +209,7 @@ def test_1(capsys):
child.expect("hello1")
child.sendeof()
child.read()
if child.isalive():
child.wait()
self.flush(child)

def test_set_trace_capturing_afterwards(self, testdir):
p1 = testdir.makepyfile("""
Expand All @@ -229,8 +228,7 @@ def test_2():
child.expect("hello")
child.sendeof()
child.read()
if child.isalive():
child.wait()
self.flush(child)

def test_pdb_interaction_doctest(self, testdir):
p1 = testdir.makepyfile("""
Expand All @@ -249,8 +247,7 @@ def function_1():
child.sendeof()
rest = child.read().decode("utf8")
assert "1 failed" in rest
if child.isalive():
child.wait()
self.flush(child)

def test_pdb_interaction_capturing_twice(self, testdir):
p1 = testdir.makepyfile("""
Expand All @@ -276,8 +273,7 @@ def test_1():
assert "def test_1" in rest
assert "hello17" in rest # out is captured
assert "hello18" in rest # out is captured
if child.isalive():
child.wait()
self.flush(child)

def test_pdb_used_outside_test(self, testdir):
p1 = testdir.makepyfile("""
Expand All @@ -288,7 +284,7 @@ def test_pdb_used_outside_test(self, testdir):
child = testdir.spawn("%s %s" %(sys.executable, p1))
child.expect("x = 5")
child.sendeof()
child.wait()
self.flush(child)

def test_pdb_used_in_generate_tests(self, testdir):
p1 = testdir.makepyfile("""
Expand All @@ -302,7 +298,7 @@ def test_foo(a):
child = testdir.spawn_pytest(str(p1))
child.expect("x = 5")
child.sendeof()
child.wait()
self.flush(child)

def test_pdb_collection_failure_is_shown(self, testdir):
p1 = testdir.makepyfile("""xxx """)
Expand Down Expand Up @@ -331,8 +327,7 @@ def test_foo():
child.expect("enter_pdb_hook")
child.send('c\n')
child.sendeof()
if child.isalive():
child.wait()
self.flush(child)

def test_pdb_custom_cls(self, testdir):
called = []
Expand Down

0 comments on commit 7f95ea3

Please sign in to comment.