Question

I am trying to log all of the output from a python unittest I have in xml. I have setUp and tearDowns for the testcase, classed, and module. All of the output is being printed to the console, yet only the testcase setUp and tearDown are showing up in the xml.

Command ran:

nodetests -s ATestModule --with-xunit --xunit-file=a.xml

output for a specific testcase is:

<testcase classname="ATestModule.FirstTestCase" name="testOne" time="0.553">    
    <system-out><![CDATA[2014-02-24 17:51:30,560 - INFO - TestData]]>
    </system-out>
</testcase>

I have setup and teardown modules defined as:

def setup_module():
  print(__name__ + "Setup module")

def teardown_module():
  print(__name__ + "Tear down module")

I used http://pythontesting.net/framework/nose/nose-fixture-reference/ as an example.

These don't show up in the test case, which is understandable, but i would still expect them to appear somewhere in the xml? Is there a setting or a different runner which would better suit my needs?

Thanks!

Was it helpful?

Solution

Here are what I found out. According to the documentation, the module-level set-up and tear-down should be named setUpModule and tearDownModule. I have tried some tests and sure enough, while those fixture functions get called, their output are not included in the output XML file.

Similarly, the class-level fixtures setUpClass and tearDownClass also get called, but not showing any output. It might be by design and I don't know how to fix it.

Update

I looked into the source code for nose and sure enough, there is no XML output for fixtures.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top