Storing the the results of unit test in python in some SQL Database
Question: I am learning the different possibilities to write and run (unit) tests in
Python. I would like to store the output of the tests in a SQL database
-preferably sqlite.

I found a way to run the tests using the nose framework from inside the code
like this:

    
    
    import nose
    import os
    
    os.chdir('./projects/project A')
    
    result = nose.run()
    
    print 'The result:', result
    

And I get the following output:

    
    
    The result: True
    ....
    ----------------------------------------------------------------------
    Ran 4 tests in 0.013s
    
    OK
    

I am forced to parse the stderr/stdout or is there any better way to get the
test results and messages for further processing ?


Answer: You can run `nosetests --with-xunit` to get the results in a standard XUnit
file format (XML). You can then parse and process that to insert it into a
database.

You can also look for a third-party plugin that writes it in a different
output format. The last option would be to write a plugin yourself.

