junitparser 3.1.1__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.1 → junitparser-3.2.0}/PKG-INFO +8 -8
  2. {junitparser-3.1.1 → junitparser-3.2.0}/README.rst +7 -7
  3. {junitparser-3.1.1 → junitparser-3.2.0}/junitparser/__init__.py +1 -1
  4. {junitparser-3.1.1 → junitparser-3.2.0}/junitparser/junitparser.py +18 -11
  5. {junitparser-3.1.1 → junitparser-3.2.0}/junitparser/xunit2.py +22 -20
  6. {junitparser-3.1.1 → junitparser-3.2.0}/junitparser.egg-info/PKG-INFO +8 -8
  7. {junitparser-3.1.1 → junitparser-3.2.0}/tests/test_general.py +2 -1
  8. {junitparser-3.1.1 → junitparser-3.2.0}/tests/test_xunit2.py +11 -0
  9. {junitparser-3.1.1 → junitparser-3.2.0}/LICENSE +0 -0
  10. {junitparser-3.1.1 → junitparser-3.2.0}/junitparser/__main__.py +0 -0
  11. {junitparser-3.1.1 → junitparser-3.2.0}/junitparser/cli.py +0 -0
  12. {junitparser-3.1.1 → junitparser-3.2.0}/junitparser/py.typed +0 -0
  13. {junitparser-3.1.1 → junitparser-3.2.0}/junitparser.egg-info/SOURCES.txt +0 -0
  14. {junitparser-3.1.1 → junitparser-3.2.0}/junitparser.egg-info/dependency_links.txt +0 -0
  15. {junitparser-3.1.1 → junitparser-3.2.0}/junitparser.egg-info/entry_points.txt +0 -0
  16. {junitparser-3.1.1 → junitparser-3.2.0}/junitparser.egg-info/not-zip-safe +0 -0
  17. {junitparser-3.1.1 → junitparser-3.2.0}/junitparser.egg-info/top_level.txt +0 -0
  18. {junitparser-3.1.1 → junitparser-3.2.0}/pyproject.toml +0 -0
  19. {junitparser-3.1.1 → junitparser-3.2.0}/setup.cfg +0 -0
  20. {junitparser-3.1.1 → junitparser-3.2.0}/setup.py +0 -0
  21. {junitparser-3.1.1 → junitparser-3.2.0}/tests/test_cli.py +0 -0
  22. {junitparser-3.1.1 → 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.1
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
@@ -28,12 +28,12 @@ existing Result XML files, or create new JUnit/xUnit result XMLs from scratch.
28
28
  Features
29
29
  --------
30
30
 
31
- * Parse or modify existing JUnit/xUnit xml files.
32
- * Parse or modify non-standard or customized JUnit/xUnit xml files, by monkey
31
+ * Parse or modify existing JUnit/xUnit XML files.
32
+ * Parse or modify non-standard or customized JUnit/xUnit XML files, by monkey
33
33
  patching existing element definitions.
34
34
  * Create JUnit/xUnit test results from scratch.
35
- * Merge test result xml files.
36
- * Specify xml parser. For example you can use lxml to speed things up.
35
+ * Merge test result XML files.
36
+ * Specify XML parser. For example you can use lxml to speed things up.
37
37
  * Invoke from command line, or `python -m junitparser`
38
38
  * Python 2 and 3 support (As of Nov 2020, 1/4 of the users are still on Python
39
39
  2, so there is no plan to drop Python 2 support)
@@ -41,7 +41,7 @@ Features
41
41
  Note on version 2
42
42
  -----------------
43
43
 
44
- Version 2 improved support for pytest result xml files by fixing a few issues,
44
+ Version 2 improved support for pytest result XML files by fixing a few issues,
45
45
  notably that there could be multiple <Failure> or <Error> entries. There is a
46
46
  breaking change that ``TestCase.result`` is now a list instead of a single item.
47
47
  If you are using this attribute, please update your code accordingly.
@@ -149,7 +149,7 @@ Schema Support
149
149
  ~~~~~~~~~~~~~~~
150
150
 
151
151
  By default junitparser supports the schema of windyroad_, which is a relatively
152
- simple schema.
152
+ simple schema.
153
153
 
154
154
  .. _windyroad: https://github.com/windyroad/JUnit-Schema/blob/master/JUnit.xsd
155
155
 
@@ -295,7 +295,7 @@ Command Line
295
295
  Test
296
296
  ----
297
297
 
298
- The tests are written with python `unittest`, to run them, use pytest::
298
+ The tests are written with python ``unittest``, to run them, use pytest::
299
299
 
300
300
  pytest test.py
301
301
 
@@ -12,12 +12,12 @@ existing Result XML files, or create new JUnit/xUnit result XMLs from scratch.
12
12
  Features
13
13
  --------
14
14
 
15
- * Parse or modify existing JUnit/xUnit xml files.
16
- * Parse or modify non-standard or customized JUnit/xUnit xml files, by monkey
15
+ * Parse or modify existing JUnit/xUnit XML files.
16
+ * Parse or modify non-standard or customized JUnit/xUnit XML files, by monkey
17
17
  patching existing element definitions.
18
18
  * Create JUnit/xUnit test results from scratch.
19
- * Merge test result xml files.
20
- * Specify xml parser. For example you can use lxml to speed things up.
19
+ * Merge test result XML files.
20
+ * Specify XML parser. For example you can use lxml to speed things up.
21
21
  * Invoke from command line, or `python -m junitparser`
22
22
  * Python 2 and 3 support (As of Nov 2020, 1/4 of the users are still on Python
23
23
  2, so there is no plan to drop Python 2 support)
@@ -25,7 +25,7 @@ Features
25
25
  Note on version 2
26
26
  -----------------
27
27
 
28
- Version 2 improved support for pytest result xml files by fixing a few issues,
28
+ Version 2 improved support for pytest result XML files by fixing a few issues,
29
29
  notably that there could be multiple <Failure> or <Error> entries. There is a
30
30
  breaking change that ``TestCase.result`` is now a list instead of a single item.
31
31
  If you are using this attribute, please update your code accordingly.
@@ -133,7 +133,7 @@ Schema Support
133
133
  ~~~~~~~~~~~~~~~
134
134
 
135
135
  By default junitparser supports the schema of windyroad_, which is a relatively
136
- simple schema.
136
+ simple schema.
137
137
 
138
138
  .. _windyroad: https://github.com/windyroad/JUnit-Schema/blob/master/JUnit.xsd
139
139
 
@@ -279,7 +279,7 @@ Command Line
279
279
  Test
280
280
  ----
281
281
 
282
- The tests are written with python `unittest`, to run them, use pytest::
282
+ The tests are written with python ``unittest``, to run them, use pytest::
283
283
 
284
284
  pytest test.py
285
285
 
@@ -14,4 +14,4 @@ from .junitparser import (
14
14
  FloatAttr,
15
15
  )
16
16
 
17
- version = "3.1.1"
17
+ version = "3.2.0"
@@ -8,9 +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
13
+ from typing import List, Union
14
14
 
15
15
  try:
16
16
  from lxml import etree
@@ -314,6 +314,7 @@ class TestCase(Element):
314
314
  name = Attr()
315
315
  classname = Attr()
316
316
  time = FloatAttr()
317
+ __test__ = False
317
318
 
318
319
  def __init__(self, name: str = None, classname: str = None, time: float = None):
319
320
  super().__init__(self._tag)
@@ -362,14 +363,17 @@ class TestCase(Element):
362
363
  return results
363
364
 
364
365
  @result.setter
365
- def result(self, value: Result):
366
+ def result(self, value: Union[Result, List[Result]]):
366
367
  # First remove all existing results
367
368
  for entry in self.result:
368
369
  if any(isinstance(entry, r) for r in POSSIBLE_RESULTS):
369
370
  self.remove(entry)
370
- for entry in value:
371
- if any(isinstance(entry, r) for r in POSSIBLE_RESULTS):
372
- 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)
373
377
 
374
378
  @property
375
379
  def system_out(self):
@@ -489,6 +493,7 @@ class TestSuite(Element):
489
493
  failures = IntAttr()
490
494
  errors = IntAttr()
491
495
  skipped = IntAttr()
496
+ __test__ = False
492
497
 
493
498
  def __init__(self, name=None):
494
499
  super().__init__(self._tag)
@@ -552,7 +557,7 @@ class TestSuite(Element):
552
557
  result.add_testsuite(other)
553
558
  return result
554
559
 
555
- def remove_testcase(self, testcase):
560
+ def remove_testcase(self, testcase: TestCase):
556
561
  """Remove testcase *testcase* from the testsuite."""
557
562
  for case in self:
558
563
  if case == testcase:
@@ -580,7 +585,7 @@ class TestSuite(Element):
580
585
  self.skipped = skipped
581
586
  self.time = round(time, 3)
582
587
 
583
- def add_property(self, name, value):
588
+ def add_property(self, name: str, value: str):
584
589
  """Add a property *name* = *value* to the testsuite.
585
590
 
586
591
  See :class:`Property` and :class:`Properties`.
@@ -593,17 +598,17 @@ class TestSuite(Element):
593
598
  prop = Property(name, value)
594
599
  props.add_property(prop)
595
600
 
596
- def add_testcase(self, testcase):
601
+ def add_testcase(self, testcase: TestCase):
597
602
  """Add a testcase *testcase* to the testsuite."""
598
603
  self.append(testcase)
599
604
  self.update_statistics()
600
605
 
601
- def add_testcases(self, testcases):
606
+ def add_testcases(self, testcases: List[TestCase]):
602
607
  """Add testcases *testcases* to the testsuite."""
603
608
  self.extend(testcases)
604
609
  self.update_statistics()
605
610
 
606
- def _add_testcase_no_update_stats(self, testcase):
611
+ def _add_testcase_no_update_stats(self, testcase: TestCase):
607
612
  """Add *testcase* to the testsuite (without updating statistics).
608
613
 
609
614
  For internal use only to avoid quadratic behaviour in merge.
@@ -662,6 +667,8 @@ class JUnitXml(Element):
662
667
  errors = IntAttr()
663
668
  skipped = IntAttr()
664
669
 
670
+ testsuite = TestSuite
671
+
665
672
  def __init__(self, name=None):
666
673
  super().__init__(self._tag)
667
674
  self.filepath = None
@@ -726,7 +733,7 @@ class JUnitXml(Element):
726
733
  if root_elem.tag == "testsuites":
727
734
  instance = cls()
728
735
  elif root_elem.tag == "testsuite":
729
- instance = TestSuite()
736
+ instance = cls.testsuite()
730
737
  else:
731
738
  raise JUnitXmlError("Invalid format.")
732
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.1
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
@@ -28,12 +28,12 @@ existing Result XML files, or create new JUnit/xUnit result XMLs from scratch.
28
28
  Features
29
29
  --------
30
30
 
31
- * Parse or modify existing JUnit/xUnit xml files.
32
- * Parse or modify non-standard or customized JUnit/xUnit xml files, by monkey
31
+ * Parse or modify existing JUnit/xUnit XML files.
32
+ * Parse or modify non-standard or customized JUnit/xUnit XML files, by monkey
33
33
  patching existing element definitions.
34
34
  * Create JUnit/xUnit test results from scratch.
35
- * Merge test result xml files.
36
- * Specify xml parser. For example you can use lxml to speed things up.
35
+ * Merge test result XML files.
36
+ * Specify XML parser. For example you can use lxml to speed things up.
37
37
  * Invoke from command line, or `python -m junitparser`
38
38
  * Python 2 and 3 support (As of Nov 2020, 1/4 of the users are still on Python
39
39
  2, so there is no plan to drop Python 2 support)
@@ -41,7 +41,7 @@ Features
41
41
  Note on version 2
42
42
  -----------------
43
43
 
44
- Version 2 improved support for pytest result xml files by fixing a few issues,
44
+ Version 2 improved support for pytest result XML files by fixing a few issues,
45
45
  notably that there could be multiple <Failure> or <Error> entries. There is a
46
46
  breaking change that ``TestCase.result`` is now a list instead of a single item.
47
47
  If you are using this attribute, please update your code accordingly.
@@ -149,7 +149,7 @@ Schema Support
149
149
  ~~~~~~~~~~~~~~~
150
150
 
151
151
  By default junitparser supports the schema of windyroad_, which is a relatively
152
- simple schema.
152
+ simple schema.
153
153
 
154
154
  .. _windyroad: https://github.com/windyroad/JUnit-Schema/blob/master/JUnit.xsd
155
155
 
@@ -295,7 +295,7 @@ Command Line
295
295
  Test
296
296
  ----
297
297
 
298
- The tests are written with python `unittest`, to run them, use pytest::
298
+ The tests are written with python ``unittest``, to run them, use pytest::
299
299
 
300
300
  pytest test.py
301
301
 
@@ -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