title: calling pytest from inside python code
body: <p>I am writing a Python script for collecting data from running tests under different conditions. At the moment, I am interested in adding support for Py.Test.</p>
  
  <p>The Py.Test documentation clearly states that running pytest inside Python code is supported:</p>
  
  <blockquote>
    <p>You can invoke pytest from Python code directly... acts as if you would call “pytest” from the command line...</p>
  </blockquote>
  
  <p>However, the <a href="http://doc.pytest.org/en/latest/usage.html#calling-pytest-from-python-code" rel="noreferrer">documentation</a> does not describe in detail return value of calling <code>pytest.main()</code> as prescribed. The documentation only seems to indicate how to read the exit code of calling the tests.</p>
  
  <p>What are the limits of data resolution available through this interface? Does this method simply return a string indicating the results of the test? Is support more friendly data structures supported (e.g., outcome of each test case assigned to key, value pair)?</p>
  
  <p><strong><em>Update</em></strong>: Examining the return data structure in the REPL reveals that calling <code>pytest.main</code> yeilds an integer return type indicating system exit code and directs a side-effect (stream of text detailing test result) to standard out. Considering this is the case, <strong>does Py.Test provide an alternate interface for accessing the result of tests run from within python code through some native data structure (e.g., dictionary)?</strong> I would like to avoid catching and parsing the std.out result because that approach seems error prone.</p>