pytest: pytest.main(...) hangs but works if run with subprocess.check_output
In my code, I call pytest.main(arguments)
to run Pytest.
arguments = ['-p', 'no:warnings', '--no-print-logs', '--junit-xml', log_path]
arguments.extend(test_paths)
if parallel:
arguments += ['-n', 'auto']
if pytest_args:
arguments += pytest_args
logger.info('Running: pytest {}'.format(' '.join(arguments)))
return pytest.main(arguments)
This code hangs when run on OSX (10.14.1) but works fine on Windows.
If I change the last line to instead essentially call pytest through subprocess.check_output
it executes fine. It also works if I simply copy-paste the command to my terminal. This behavior is observed whether I specify -n=auto
or not, which is why I’m posting this here instead of in pytest-xdist. Is there something I’m doing wrong here?
Pip List
pytest (4.0.0)
pytest-forked (0.2)
pytest-xdist (1.24.1)
OS Info
Python (Darwin) 2.7.10 (default, Aug 17 2018, 17:41:52)
[GCC 4.2.1 Compatible Apple LLVM 10.0.0 (clang-1000.0.42)]
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 26 (11 by maintainers)
@nicoddemus - You are awesome!
@tjprescott - Are you also accidentally running pytest from pytest like we are? Or is it a different one? If the second, I am really sorry for derailing your issue report; I should have opened a separate issue.
@astrofrog - I will send PRs with the one-line change for the Astropy and package-template repos.
@nicoddemus - thank you for diagnosing this!