[Pytest-commit] Issue #632: Empty classname in junitxml for collection failure (hpk42/pytest)

Colin Blackburn issues-reply at bitbucket.org
Mon Nov 17 11:53:39 CET 2014


New issue 632: Empty classname in junitxml for collection failure
https://bitbucket.org/hpk42/pytest/issue/632/empty-classname-in-junitxml-for-collection

Colin Blackburn:

If there is a fail of some sort at the module or class level the tests are not collected. The failure as reported in the junitxml file has an empty classname. This causes problems in downstream reporting on Jenkins where a link to the error report cannot be correctly formed.

Here are three example test files:
```
#!python
# file name: test.integration.junit.test_class

class TestClass(object):

    UL = []
    UL._non_atrrib

    def testClass(self):
        assert True
```


```
#!python
# file name: test.integration.junit.test_module

UL = []
UL._non_atrrib

class TestModule(object):

    def testModule(self):
        assert True
```


```
#!python
# file name: test.integration.junit.test_method

class TestMethod(object):

    def testMethod(self):
    	UL = []
    	UL._non_atrrib
        assert True
```

which give this XML output:

```
#!xml

<?xml version="1.0" encoding="utf-8"?>
<testsuite errors="2" failures="1" name="pytest" skips="0" tests="1" time="0.030">
  <testcase classname="" name="test.integration.junit.test_class" time="0">
    <error message="collection failure">test/integration/junit/test_class.py:5: in <module>
    class TestClass(object):
test/integration/junit/test_class.py:8: in TestClass
    UL._non_atrrib
E   AttributeError: 'list' object has no attribute '_non_atrrib'</error>
  </testcase>
  <testcase classname="" name="test.integration.junit.test_module" time="0">
    <error message="collection failure">test/integration/junit/test_module.py:6: in <module>
    UL._non_atrrib
E   AttributeError: 'list' object has no attribute '_non_atrrib'</error>
  </testcase>
  <testcase classname="test.integration.junit.test_method.TestMethod" name="testMethod" time="0.000324010848999">
    <failure message="test failure">self = <test_method.TestMethod object at 0x10b61a6d0>

    def testMethod(self):
        UL = []
>       UL._non_atrrib
E       AttributeError: 'list' object has no attribute '_non_atrrib'

test/integration/junit/test_method.py:9: AttributeError</failure>
  </testcase>
</testsuite>
```




More information about the pytest-commit mailing list