Skip to content Skip to sidebar Skip to footer

Pytest.main() Capture Standard Output

I have a method I am using to get all of the tests we have. def get_test_names_from_file(): get_test_names = pytest.main(['--collect-only', '-q']) print(type(get_test_nam

Solution 1:

You could use py.io for this.

something like:

capture = py.io.StdCapture()
pytest.main(['--collect-only', '-q'])
std, err = capture.reset()
print(std)

Would get you the standard output you're looking for.

Post a Comment for "Pytest.main() Capture Standard Output"