weiwei / junitparser

Parses JUnit/xUnit Result XML files with ease
https://junitparser.readthedocs.io
Other
120 stars 52 forks source link

pytest generates warning when importing `TestSuite` in test file #124

Closed kurtsansom closed 9 months ago

kurtsansom commented 9 months ago

with pytest warnings are generated when importing in test file. e.g. from junitparser import JUnitXml, TestSuite

generates a warning when pytest is executed:

PytestCollectionWarning: cannot collect test class 'TestSuite' because it has a __init__ constructor (from: tests/test_utils.py)
    class TestSuite(Element):

It seems like the fix is to add __test__ = False to each class that starts with Test*

I happy to make that pull request but not sure if that is the best solution.

EDIT: when running pytest against the junitparser project it gives me similar warnings and when __test__ = False is added to TestCase and TestSuite the warnings go away.

EDIT: #125 includes the fix for the warnings.

kurtsansom commented 9 months ago

closed by #125