I am writing a Python script to collect data from running tests under different conditions. I'm currently interested in adding Py.Test support.
The Py.Test documentation clearly states that pytest works inside Python code:
You can call pytest from Python code directly ... acts as if you were calling "pytest" from the command line ...
However, the documentation does not describe in detail the return value of the call pytest.main()as prescribed. The documentation seems to indicate how to read the exit code to call the tests.
What are the data resolution limits available through this interface? Does this method just return a string indicating the test results? Is support for friendlier data structures supported (for example, the result of each test case assigned to a key pair, values)?
Update . Examining the structure of the returned data in REPL shows that calling pytest.mainyeilds returns an integer return type indicating the system exit code and directs the side effect (text stream detailing the test result) to the standard outside. Given that this is so, does Py.Test offer an alternative interface for accessing test results executed from python code through some proprietary data structure (e.g. a dictionary)? I would like to avoid catching and analyzing the result of std.out, as this approach seems error prone.
source
share