junitparser 3.1.2__tar.gz → 3.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (22) hide show
  1. {junitparser-3.1.2 → junitparser-3.2.0}/PKG-INFO +1 -1
  2. {junitparser-3.1.2 → junitparser-3.2.0}/junitparser/__init__.py +1 -1
  3. {junitparser-3.1.2 → junitparser-3.2.0}/junitparser/junitparser.py +11 -7
  4. {junitparser-3.1.2 → junitparser-3.2.0}/junitparser/xunit2.py +22 -20
  5. {junitparser-3.1.2 → junitparser-3.2.0}/junitparser.egg-info/PKG-INFO +1 -1
  6. {junitparser-3.1.2 → junitparser-3.2.0}/tests/test_general.py +2 -1
  7. {junitparser-3.1.2 → junitparser-3.2.0}/tests/test_xunit2.py +11 -0
  8. {junitparser-3.1.2 → junitparser-3.2.0}/LICENSE +0 -0
  9. {junitparser-3.1.2 → junitparser-3.2.0}/README.rst +0 -0
  10. {junitparser-3.1.2 → junitparser-3.2.0}/junitparser/__main__.py +0 -0
  11. {junitparser-3.1.2 → junitparser-3.2.0}/junitparser/cli.py +0 -0
  12. {junitparser-3.1.2 → junitparser-3.2.0}/junitparser/py.typed +0 -0
  13. {junitparser-3.1.2 → junitparser-3.2.0}/junitparser.egg-info/SOURCES.txt +0 -0
  14. {junitparser-3.1.2 → junitparser-3.2.0}/junitparser.egg-info/dependency_links.txt +0 -0
  15. {junitparser-3.1.2 → junitparser-3.2.0}/junitparser.egg-info/entry_points.txt +0 -0
  16. {junitparser-3.1.2 → junitparser-3.2.0}/junitparser.egg-info/not-zip-safe +0 -0
  17. {junitparser-3.1.2 → junitparser-3.2.0}/junitparser.egg-info/top_level.txt +0 -0
  18. {junitparser-3.1.2 → junitparser-3.2.0}/pyproject.toml +0 -0
  19. {junitparser-3.1.2 → junitparser-3.2.0}/setup.cfg +0 -0
  20. {junitparser-3.1.2 → junitparser-3.2.0}/setup.py +0 -0
  21. {junitparser-3.1.2 → junitparser-3.2.0}/tests/test_cli.py +0 -0
  22. {junitparser-3.1.2 → junitparser-3.2.0}/tests/test_fromfile.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: junitparser
3
- Version: 3.1.2
3
+ Version: 3.2.0
4
4
  Summary: Manipulates JUnit/xUnit Result XML files
5
5
  Home-page: https://github.com/weiwei/junitparser
6
6
  Author: Weiwei Wang
@@ -14,4 +14,4 @@ from .junitparser import (
14
14
  FloatAttr,
15
15
  )
16
16
 
17
- version = "3.1.2"
17
+ version = "3.2.0"
@@ -8,10 +8,9 @@ This, according to the document, is Apache Ant's JUnit output.
8
8
 
9
9
  See the documentation for other supported schemas.
10
10
  """
11
-
12
11
  import itertools
13
12
  from copy import deepcopy
14
- from typing import List
13
+ from typing import List, Union
15
14
 
16
15
  try:
17
16
  from lxml import etree
@@ -364,14 +363,17 @@ class TestCase(Element):
364
363
  return results
365
364
 
366
365
  @result.setter
367
- def result(self, value: Result):
366
+ def result(self, value: Union[Result, List[Result]]):
368
367
  # First remove all existing results
369
368
  for entry in self.result:
370
369
  if any(isinstance(entry, r) for r in POSSIBLE_RESULTS):
371
370
  self.remove(entry)
372
- for entry in value:
373
- if any(isinstance(entry, r) for r in POSSIBLE_RESULTS):
374
- self.append(entry)
371
+ if isinstance(value, Result):
372
+ self.append(value)
373
+ elif isinstance(value, list):
374
+ for entry in value:
375
+ if any(isinstance(entry, r) for r in POSSIBLE_RESULTS):
376
+ self.append(entry)
375
377
 
376
378
  @property
377
379
  def system_out(self):
@@ -665,6 +667,8 @@ class JUnitXml(Element):
665
667
  errors = IntAttr()
666
668
  skipped = IntAttr()
667
669
 
670
+ testsuite = TestSuite
671
+
668
672
  def __init__(self, name=None):
669
673
  super().__init__(self._tag)
670
674
  self.filepath = None
@@ -729,7 +733,7 @@ class JUnitXml(Element):
729
733
  if root_elem.tag == "testsuites":
730
734
  instance = cls()
731
735
  elif root_elem.tag == "testsuite":
732
- instance = TestSuite()
736
+ instance = cls.testsuite()
733
737
  else:
734
738
  raise JUnitXmlError("Invalid format.")
735
739
  instance._elem = root_elem
@@ -19,26 +19,6 @@ from . import junitparser
19
19
  T = TypeVar("T")
20
20
 
21
21
 
22
- class JUnitXml(junitparser.JUnitXml):
23
- # Pytest and xunit schema doesn't have "skipped" in testsuites
24
- skipped = None
25
-
26
- def update_statistics(self):
27
- """Update test count, time, etc."""
28
- time = 0
29
- tests = failures = errors = 0
30
- for suite in self:
31
- suite.update_statistics()
32
- tests += suite.tests
33
- failures += suite.failures
34
- errors += suite.errors
35
- time += suite.time
36
- self.tests = tests
37
- self.failures = failures
38
- self.errors = errors
39
- self.time = round(time, 3)
40
-
41
-
42
22
  class TestSuite(junitparser.TestSuite):
43
23
  """TestSuite for Pytest, with some different attributes."""
44
24
 
@@ -93,6 +73,28 @@ class TestSuite(junitparser.TestSuite):
93
73
  self.append(err)
94
74
 
95
75
 
76
+ class JUnitXml(junitparser.JUnitXml):
77
+ # Pytest and xunit schema doesn't have "skipped" in testsuites
78
+ skipped = None
79
+
80
+ testsuite = TestSuite
81
+
82
+ def update_statistics(self):
83
+ """Update test count, time, etc."""
84
+ time = 0
85
+ tests = failures = errors = 0
86
+ for suite in self:
87
+ suite.update_statistics()
88
+ tests += suite.tests
89
+ failures += suite.failures
90
+ errors += suite.errors
91
+ time += suite.time
92
+ self.tests = tests
93
+ self.failures = failures
94
+ self.errors = errors
95
+ self.time = round(time, 3)
96
+
97
+
96
98
  class StackTrace(junitparser.System):
97
99
  _tag = "stackTrace"
98
100
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: junitparser
3
- Version: 3.1.2
3
+ Version: 3.2.0
4
4
  Summary: Manipulates JUnit/xUnit Result XML files
5
5
  Home-page: https://github.com/weiwei/junitparser
6
6
  Author: Weiwei Wang
@@ -578,7 +578,8 @@ class Test_TestCase:
578
578
 
579
579
  def test_update_results(self):
580
580
  case = TestCase()
581
- case.result = [Skipped()]
581
+ case.result = Skipped()
582
+ assert len(case.result) == 1
582
583
  case.result = [Failure(), Skipped()]
583
584
  assert len(case.result) == 2
584
585
 
@@ -101,3 +101,14 @@ class Test_JUnitXml:
101
101
  assert xml.skipped is None
102
102
  assert xml.tostring().count(b"errors") == 2
103
103
  assert xml.tostring().count(b"skipped") == 1
104
+
105
+ def test_fromstring(self):
106
+ text = """<testsuite name="suite name">
107
+ <testcase name="test name 1"/>
108
+ <testcase name="test name 2"/>
109
+ </testsuite>"""
110
+ suite = JUnitXml.fromstring(text)
111
+ assert isinstance(suite, TestSuite)
112
+ assert suite.name == "suite name"
113
+ assert len(list(suite)) == 2
114
+ assert [test.name for test in suite] == ["test name 1", "test name 2"]
File without changes
File without changes
File without changes
File without changes
File without changes