pytest-json-ctrf 0.1.2__tar.gz → 0.2.3__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.3
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
@@ -91,3 +97,6 @@ More info here: https://ctrf.io/docs/schema/examples
91
97
  - https://github.com/testomatio/pytestomatio -> Source of inspiration for creating pytest plugins
92
98
  - https://github.com/infopulse/Playwright-course-python -> The report will be used in the demo project as +1 report option
93
99
 
100
+ ### Roadmap
101
+ - Add screenshots handling
102
+ - Add hooks for the report extension
@@ -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
@@ -76,3 +82,6 @@ More info here: https://ctrf.io/docs/schema/examples
76
82
  - https://github.com/testomatio/pytestomatio -> Source of inspiration for creating pytest plugins
77
83
  - https://github.com/infopulse/Playwright-course-python -> The report will be used in the demo project as +1 report option
78
84
 
85
+ ### Roadmap
86
+ - Add screenshots handling
87
+ - Add hooks for the report extension
@@ -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,13 +33,20 @@ 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:
39
45
  self.status = TestStatus.OTHER
40
46
 
41
47
  def update(self, report: TestReport, worker_id: str = None) -> None:
42
- self.name = report.head_line.split('[')[0]
48
+ self.name = report.nodeid.split('[')[0]
49
+ # self.name = report.head_line.split('[')[0]
43
50
  self.set_status(report)
44
51
  self.duration += report.duration
45
52
  if report.when == "setup" and not self.start:
@@ -66,7 +73,8 @@ class TestObject:
66
73
  'file_path': self.file_path,
67
74
  'tags': self.tags,
68
75
  'browser': self.browser,
69
- 'trace': self.trace
76
+ 'trace': self.trace,
77
+ 'message': self.message
70
78
  }
71
79
  if self.worker_id:
72
80
  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.3"
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.3
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
@@ -91,3 +97,6 @@ More info here: https://ctrf.io/docs/schema/examples
91
97
  - https://github.com/testomatio/pytestomatio -> Source of inspiration for creating pytest plugins
92
98
  - https://github.com/infopulse/Playwright-course-python -> The report will be used in the demo project as +1 report option
93
99
 
100
+ ### Roadmap
101
+ - Add screenshots handling
102
+ - Add hooks for the report extension