pytest-json-ctrf 0.1.2__tar.gz → 0.2.1__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pytest-json-ctrf
3
- Version: 0.1.2
3
+ Version: 0.2.1
4
4
  Summary: Pytest plugin to generate json report in CTRF (Common Test Report Format)
5
5
  Author: Oleksii Ostapov
6
6
  Project-URL: Infopulse, https://infopulse.com/
@@ -84,6 +84,12 @@ More info here: https://ctrf.io/docs/schema/examples
84
84
  ## Report Example
85
85
  ![Example Image](./assets/report_example.png)
86
86
 
87
+ ## Technical details
88
+ For future me and others who are interested in the technical details of the implementation.
89
+ The main idea is to handle xdist plugin because without it collecting report is quite straightforward.
90
+ By the example of putest-json-report plugin, I have learned that different plugins can be registered for the controller and workers node.
91
+ The `pytest_runtest_logreport` hook in the controller node is used to collect the test results from all the nodes so other nodes can just add some details to the `TestReport` object.
92
+
87
93
  ## Credits
88
94
 
89
95
  - https://ctrf.io/ -> nice data format
@@ -69,6 +69,12 @@ More info here: https://ctrf.io/docs/schema/examples
69
69
  ## Report Example
70
70
  ![Example Image](./assets/report_example.png)
71
71
 
72
+ ## Technical details
73
+ For future me and others who are interested in the technical details of the implementation.
74
+ The main idea is to handle xdist plugin because without it collecting report is quite straightforward.
75
+ By the example of putest-json-report plugin, I have learned that different plugins can be registered for the controller and workers node.
76
+ The `pytest_runtest_logreport` hook in the controller node is used to collect the test results from all the nodes so other nodes can just add some details to the `TestReport` object.
77
+
72
78
  ## Credits
73
79
 
74
80
  - https://ctrf.io/ -> nice data format
@@ -1,7 +1,6 @@
1
1
  from enum import Enum
2
2
  from pytest import TestReport
3
3
 
4
-
5
4
  class TestStatus(Enum):
6
5
  PASSED = "passed"
7
6
  FAILED = "failed"
@@ -18,6 +17,7 @@ class TestObject:
18
17
  start: float = None
19
18
  stop: float = None
20
19
  retries: int = 0
20
+ message: str = ''
21
21
 
22
22
  worker_id: str = None
23
23
  file_path: str = None
@@ -33,6 +33,12 @@ class TestObject:
33
33
  elif report.failed:
34
34
  self.status = TestStatus.FAILED
35
35
  self.raw_status = f"{report.when}_{report.outcome}"
36
+ self.message = f"The test failed in the {report.when} phase"
37
+ if hasattr(report, 'longreprtext'):
38
+ if "AssertionError" in report.longreprtext:
39
+ self.message += " due to an assertion error"
40
+ elif "Exception" in report.longreprtext:
41
+ self.message += " due to an exception"
36
42
  elif report.passed:
37
43
  self.status = TestStatus.PASSED
38
44
  else:
@@ -66,7 +72,8 @@ class TestObject:
66
72
  'file_path': self.file_path,
67
73
  'tags': self.tags,
68
74
  'browser': self.browser,
69
- 'trace': self.trace
75
+ 'trace': self.trace,
76
+ 'message': self.message
70
77
  }
71
78
  if self.worker_id:
72
79
  result['extra'] = {'worker': self.worker_id}
@@ -7,7 +7,7 @@ exclude = [".github", "tests", "build", "dist", ".venv", "pytestomatio.egg-info"
7
7
 
8
8
  [project]
9
9
  name = "pytest-json-ctrf"
10
- version = "0.1.2"
10
+ version = "0.2.1"
11
11
 
12
12
  dependencies = [
13
13
  "pytest>6.0.0",
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pytest-json-ctrf
3
- Version: 0.1.2
3
+ Version: 0.2.1
4
4
  Summary: Pytest plugin to generate json report in CTRF (Common Test Report Format)
5
5
  Author: Oleksii Ostapov
6
6
  Project-URL: Infopulse, https://infopulse.com/
@@ -84,6 +84,12 @@ More info here: https://ctrf.io/docs/schema/examples
84
84
  ## Report Example
85
85
  ![Example Image](./assets/report_example.png)
86
86
 
87
+ ## Technical details
88
+ For future me and others who are interested in the technical details of the implementation.
89
+ The main idea is to handle xdist plugin because without it collecting report is quite straightforward.
90
+ By the example of putest-json-report plugin, I have learned that different plugins can be registered for the controller and workers node.
91
+ The `pytest_runtest_logreport` hook in the controller node is used to collect the test results from all the nodes so other nodes can just add some details to the `TestReport` object.
92
+
87
93
  ## Credits
88
94
 
89
95
  - https://ctrf.io/ -> nice data format