New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pexpect tests hang on macOS #2022

jaraco opened this Issue Oct 21, 2016 · 2 comments


None yet
2 participants

jaraco commented Oct 21, 2016

In #985, I discovered that many tests on macOS are bypassed because pexpect appears to operate unreliably on that platform.


This comment has been minimized.


jaraco commented Oct 21, 2016

I found that even consuming all of the input before calling .wait() doesn't stop the block forever behavior. But if instead I do something like the following, it causes child.isalive() to return False and the test to pass.

diff -r 1d9397a85c2c testing/
--- a/testing/   Fri Oct 21 01:36:24 2016 +0200
+++ b/testing/   Fri Oct 21 12:01:25 2016 -0400
@@ -141,10 +141,20 @@
         child = testdir.spawn_pytest("--pdb %s" % p1)
         #child.expect(".*import pytest.*")
+        print("got here 1")
+        print("got here 2")
         child.expect("1 error")
+        print("got here 3")
+        while True:
+            try:
+                child.read_nonblocking()
+            except Exception:
+                break
         if child.isalive():
+            print("got here 6")
+        print("got here 5")

     def test_pdb_interaction_on_internal_error(self, testdir):
$ python -m tox -e py35 -- -s -k test_pdb_interaction_on_collection_issue181 -v
GLOB sdist-make: /Users/jaraco/Dropbox/code/public/pytest/
py35 inst-nodeps: /Users/jaraco/Dropbox/code/public/pytest/.tox/dist/
py35 installed: hypothesis==3.5.3,mock==2.0.0,nose==1.3.7,pbr==1.10.0,pexpect==4.2.1,ptyprocess==0.5.1,py==1.4.31,pytest==3.0.4.dev0,requests==2.11.1,six==1.10.0,spark-parser==1.4.0,uncompyle6==2.9.2,xdis==3.1.0
py35 runtests: PYTHONHASHSEED='1622146962'
py35 runtests: commands[0] | pytest --lsof -rfsxX -s -k test_pdb_interaction_on_collection_issue181 -v
=========================================== test session starts ===========================================
platform darwin -- Python 3.5.2,, py-1.4.31, pluggy-0.4.0 -- /Users/jaraco/Dropbox/code/public/pytest/.tox/py35/bin/python3.5
cachedir: .cache
rootdir: /Users/jaraco/Dropbox/code/public/pytest, inifile: tox.ini
plugins: hypothesis-3.5.3
collected 1724 items 

testing/ got here 1
got here 2
got here 3
got here 5

========================================== 1723 tests deselected ==========================================
================================ 1 passed, 1723 deselected in 2.42 seconds ================================
_________________________________________________ summary _________________________________________________
  py35: commands succeeded
  congratulations :)

@jaraco jaraco changed the title from pexpect tests fail on macOS to pexpect tests hang on macOS Oct 21, 2016


This comment has been minimized.


brianmaissy commented Jan 12, 2018

Reappeared in test_pdb_custom_cls_with_settrace in d75748e, I'll open a PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment