Reputation: 2087
I'm running a module that runs nosetests with a timer like this:
import nose
from nosetimer import plugin
from collections import defaultdict
import time
import pandas as pd
plugin = plugin.TimerPlugin()
plugin.enabled = True
plugin.timer_ok = 1000
plugin.timer_warning = 2000
plugin.timer_no_color = False
logList = defaultdict(list)
nose.run(plugins=[plugin])
result = plugin._timed_tests
for test in result:
logList[test].append(result[test])
And I was wondering if it's possible to get a mapping of each test name to pass/fail/error like this:
{
'example.file.path.test1': 'pass',
'example.file.path.test2': 'pass',
'example.file.test3': 'fail',
'example.file.test4': 'pass',
'example.file.path2.test5': 'error',
'example.file.path2.test6': 'pass'
}
But without reading stdout. In other words, is there a location that nose stores this information? I've been reading the documentation and code for hours with no luck, so I feel like I may be missing something.
Upvotes: 3
Views: 976
Reputation: 6567
You can also piggy back on nosetests --with-xunit
(nose.plugins.xunit.Xunit) that will produce an xml of your test results. You can easily parse the resulting xml and extract the data you want.
Upvotes: 2
Reputation: 26160
This data is available, but at least as far as I can recall off the top of my head, the only way at it is using the nose plugin interface to write your own plugin. Plugins aren't really that complicated though, especially for something like this. You'd need the pass, fail/error, and start test hooks, along with test.address(), to get something like this working, if memory serves.
Upvotes: 2