pytest-json-ctrf 0.3.6__tar.gz → 0.4.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.
Files changed (18) hide show
  1. {pytest_json_ctrf-0.3.6 → pytest_json_ctrf-0.4.1}/PKG-INFO +17 -3
  2. {pytest_json_ctrf-0.3.6 → pytest_json_ctrf-0.4.1}/README.md +16 -2
  3. {pytest_json_ctrf-0.3.6 → pytest_json_ctrf-0.4.1}/ctrf/Report.py +11 -2
  4. {pytest_json_ctrf-0.3.6 → pytest_json_ctrf-0.4.1}/ctrf/TestObject.py +16 -16
  5. {pytest_json_ctrf-0.3.6 → pytest_json_ctrf-0.4.1}/pyproject.toml +8 -2
  6. {pytest_json_ctrf-0.3.6 → pytest_json_ctrf-0.4.1}/pytest_json_ctrf.egg-info/PKG-INFO +17 -3
  7. {pytest_json_ctrf-0.3.6 → pytest_json_ctrf-0.4.1}/ctrf/BaseMetadataReport.py +0 -0
  8. {pytest_json_ctrf-0.3.6 → pytest_json_ctrf-0.4.1}/ctrf/CommonTestReportPlugin.py +0 -0
  9. {pytest_json_ctrf-0.3.6 → pytest_json_ctrf-0.4.1}/ctrf/__init__.py +0 -0
  10. {pytest_json_ctrf-0.3.6 → pytest_json_ctrf-0.4.1}/ctrf/main.py +0 -0
  11. {pytest_json_ctrf-0.3.6 → pytest_json_ctrf-0.4.1}/pytest_json_ctrf.egg-info/SOURCES.txt +0 -0
  12. {pytest_json_ctrf-0.3.6 → pytest_json_ctrf-0.4.1}/pytest_json_ctrf.egg-info/dependency_links.txt +0 -0
  13. {pytest_json_ctrf-0.3.6 → pytest_json_ctrf-0.4.1}/pytest_json_ctrf.egg-info/entry_points.txt +0 -0
  14. {pytest_json_ctrf-0.3.6 → pytest_json_ctrf-0.4.1}/pytest_json_ctrf.egg-info/requires.txt +0 -0
  15. {pytest_json_ctrf-0.3.6 → pytest_json_ctrf-0.4.1}/pytest_json_ctrf.egg-info/top_level.txt +0 -0
  16. {pytest_json_ctrf-0.3.6 → pytest_json_ctrf-0.4.1}/setup.cfg +0 -0
  17. {pytest_json_ctrf-0.3.6 → pytest_json_ctrf-0.4.1}/tests/test_example.py +0 -0
  18. {pytest_json_ctrf-0.3.6 → pytest_json_ctrf-0.4.1}/tests/test_plugin.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pytest-json-ctrf
3
- Version: 0.3.6
3
+ Version: 0.4.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/
@@ -9,7 +9,7 @@ Classifier: Framework :: Pytest
9
9
  Classifier: Programming Language :: Python :: 3
10
10
  Classifier: License :: OSI Approved :: MIT License
11
11
  Classifier: Operating System :: OS Independent
12
- Requires-Python: >=3.9
12
+ Requires-Python: >=3.8
13
13
  Description-Content-Type: text/markdown
14
14
  Requires-Dist: pytest>6.0.0
15
15
 
@@ -39,8 +39,16 @@ generate report.json file in the root directory of the project. File path is man
39
39
  ```bash
40
40
  pytest --ctrf report.json
41
41
  ```
42
+ Environment Variables may be used to specify the required Environment Object
43
+ fields when using the CTRF [slack-test-reporter][ctrf-slack-test-reporter-url].
42
44
 
43
- ## Json exampe
45
+ ```bash
46
+ CTRF_BUILD_NAME="Pytest JSON CTRF Report"
47
+ CTRF_BUILD_NUMBER="000"
48
+ CTRF_BUILD_URL="https://ctrf.io]"
49
+ ```
50
+
51
+ ## JSON example
44
52
 
45
53
  More info here: https://ctrf.io/docs/schema/examples
46
54
 
@@ -60,6 +68,11 @@ More info here: https://ctrf.io/docs/schema/examples
60
68
  "start": 1706644023,
61
69
  "stop": 1706644043
62
70
  },
71
+ "environment": {
72
+ "buildName": "Pytest JSON CTRF Report",
73
+ "buildNumber": "000",
74
+ "buildUrl": "https://ctrf.io"
75
+ },
63
76
  "tests": [
64
77
  {
65
78
  "name": "User should be able to login",
@@ -100,3 +113,4 @@ The `pytest_runtest_logreport` hook in the controller node is used to collect th
100
113
  ### Roadmap
101
114
  - Add screenshots handling
102
115
  - Add hooks for the report extension
116
+ - [ctrf-slack-test-reporter-url]: https://github.com/ctrf-io/slack-test-reporter
@@ -24,8 +24,16 @@ generate report.json file in the root directory of the project. File path is man
24
24
  ```bash
25
25
  pytest --ctrf report.json
26
26
  ```
27
+ Environment Variables may be used to specify the required Environment Object
28
+ fields when using the CTRF [slack-test-reporter][ctrf-slack-test-reporter-url].
27
29
 
28
- ## Json exampe
30
+ ```bash
31
+ CTRF_BUILD_NAME="Pytest JSON CTRF Report"
32
+ CTRF_BUILD_NUMBER="000"
33
+ CTRF_BUILD_URL="https://ctrf.io]"
34
+ ```
35
+
36
+ ## JSON example
29
37
 
30
38
  More info here: https://ctrf.io/docs/schema/examples
31
39
 
@@ -45,6 +53,11 @@ More info here: https://ctrf.io/docs/schema/examples
45
53
  "start": 1706644023,
46
54
  "stop": 1706644043
47
55
  },
56
+ "environment": {
57
+ "buildName": "Pytest JSON CTRF Report",
58
+ "buildNumber": "000",
59
+ "buildUrl": "https://ctrf.io"
60
+ },
48
61
  "tests": [
49
62
  {
50
63
  "name": "User should be able to login",
@@ -84,4 +97,5 @@ The `pytest_runtest_logreport` hook in the controller node is used to collect th
84
97
 
85
98
  ### Roadmap
86
99
  - Add screenshots handling
87
- - Add hooks for the report extension
100
+ - Add hooks for the report extension
101
+ - [ctrf-slack-test-reporter-url]: https://github.com/ctrf-io/slack-test-reporter
@@ -16,10 +16,10 @@ class Report:
16
16
  self.stop_time = None
17
17
 
18
18
  def start(self) -> None:
19
- self.start_time = time.time()
19
+ self.start_time = int(time.time() * 1000)
20
20
 
21
21
  def stop(self) -> None:
22
- self.stop_time = time.time()
22
+ self.stop_time = int(time.time() * 1000)
23
23
 
24
24
  @staticmethod
25
25
  def _get_tool() -> dict:
@@ -43,6 +43,14 @@ class Report:
43
43
  'stop': self.stop_time
44
44
  }
45
45
 
46
+ @staticmethod
47
+ def _get_environment() -> dict:
48
+ return {
49
+ "buildName": os.getenv("CTRF_BUILD_NAME", "Pytest JSON CTRF Report"),
50
+ "buildNumber": os.getenv("CTRF_BUILD_NUMBER", "000"),
51
+ "buildUrl": os.getenv("CTRF_BUILD_URL", "https://ctrf.io"),
52
+ }
53
+
46
54
  def collect(self, report: TestReport) -> None:
47
55
  if report.nodeid not in self.test_items.keys():
48
56
  worker_id = getattr(report, 'worker_id', None)
@@ -73,6 +81,7 @@ class Report:
73
81
  return {'results': {
74
82
  "tool": self._get_tool(),
75
83
  "summary": self._get_summary(),
84
+ "environment": self._get_environment(),
76
85
  "tests": [test.serialize() for test in self.prepared_tests.values()]
77
86
  }
78
87
  }
@@ -1,5 +1,5 @@
1
1
  from enum import Enum
2
- from typing import Any
2
+ from typing import Any, Optional, List, Dict
3
3
 
4
4
  from pytest import TestReport
5
5
 
@@ -15,20 +15,20 @@ class TestStatus(Enum):
15
15
  class TestObject:
16
16
  name: str
17
17
  _status: TestStatus
18
- raw_status: str
19
- duration: float = 0
20
- start: float
21
- stop: float
18
+ raw_status: Optional[str]
19
+ duration: int = 0
20
+ start: int
21
+ stop: int
22
22
  retries: int
23
- message: str
23
+ message: Optional[str]
24
24
 
25
- worker_id: str
25
+ worker_id: Optional[str]
26
26
  file_path: str
27
- tags: list[str]
28
- browser: str
29
- trace: str
27
+ tags: List[str]
28
+ browser: Optional[str]
29
+ trace: Optional[str]
30
30
 
31
- def __init__(self, report: TestReport, worker_id: str or None = None):
31
+ def __init__(self, report: TestReport, worker_id: Optional[str] = None):
32
32
  self.name = report.nodeid.split('[')[0]
33
33
  self._status = TestStatus.PENDING
34
34
  self._status = self.set_status(report)
@@ -41,7 +41,7 @@ class TestObject:
41
41
 
42
42
  self.worker_id = worker_id
43
43
  self.file_path = report.location[0]
44
- self.tags = []
44
+ self.tags: List[str] = []
45
45
  self.browser = None
46
46
  self.trace = None
47
47
 
@@ -79,11 +79,11 @@ class TestObject:
79
79
 
80
80
  def update(self, report: TestReport) -> None:
81
81
  self.set_status(report)
82
- self.duration += 1000 * report.duration # pytest reports duration in seconds, CTRF requires milliseconds
83
82
  if report.when == "setup" and self.start == 0:
84
- self.start = report.start
83
+ self.start = int(report.start * 1000)
85
84
  if report.when == "teardown" and self.stop == 0:
86
- self.stop = report.stop
85
+ self.stop = int(report.stop * 1000)
86
+ self.duration = self.stop - self.start
87
87
  if report.longrepr and len(report.longreprtext) > 0:
88
88
  self.trace = report.longreprtext
89
89
  if hasattr(report, '_ctrf_metadata'):
@@ -91,7 +91,7 @@ class TestObject:
91
91
  self.browser = report._ctrf_metadata.get('browser')
92
92
 
93
93
  def serialize(self) -> dict:
94
- result: dict[str, Any] = {
94
+ result: Dict[str, Any] = {
95
95
  'name': self.name,
96
96
  'status': self._status.value,
97
97
  'raw_status': self.raw_status,
@@ -10,7 +10,7 @@ exclude = [
10
10
 
11
11
  [project]
12
12
  name = "pytest-json-ctrf"
13
- version = "0.3.6"
13
+ version = "0.4.1"
14
14
 
15
15
  dependencies = [
16
16
  "pytest>6.0.0",
@@ -21,7 +21,7 @@ authors = [
21
21
  ]
22
22
  description = "Pytest plugin to generate json report in CTRF (Common Test Report Format)"
23
23
  readme = "README.md"
24
- requires-python = ">=3.9"
24
+ requires-python = ">=3.8"
25
25
  classifiers = [
26
26
  "Framework :: Pytest",
27
27
  "Programming Language :: Python :: 3",
@@ -41,3 +41,9 @@ markers = [
41
41
 
42
42
  [project.entry-points.pytest11]
43
43
  ctrf = "ctrf.main"
44
+
45
+ [tool.uv]
46
+ dev-dependencies = [
47
+ "pytest-xdist>=2.0.0",
48
+ ]
49
+
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pytest-json-ctrf
3
- Version: 0.3.6
3
+ Version: 0.4.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/
@@ -9,7 +9,7 @@ Classifier: Framework :: Pytest
9
9
  Classifier: Programming Language :: Python :: 3
10
10
  Classifier: License :: OSI Approved :: MIT License
11
11
  Classifier: Operating System :: OS Independent
12
- Requires-Python: >=3.9
12
+ Requires-Python: >=3.8
13
13
  Description-Content-Type: text/markdown
14
14
  Requires-Dist: pytest>6.0.0
15
15
 
@@ -39,8 +39,16 @@ generate report.json file in the root directory of the project. File path is man
39
39
  ```bash
40
40
  pytest --ctrf report.json
41
41
  ```
42
+ Environment Variables may be used to specify the required Environment Object
43
+ fields when using the CTRF [slack-test-reporter][ctrf-slack-test-reporter-url].
42
44
 
43
- ## Json exampe
45
+ ```bash
46
+ CTRF_BUILD_NAME="Pytest JSON CTRF Report"
47
+ CTRF_BUILD_NUMBER="000"
48
+ CTRF_BUILD_URL="https://ctrf.io]"
49
+ ```
50
+
51
+ ## JSON example
44
52
 
45
53
  More info here: https://ctrf.io/docs/schema/examples
46
54
 
@@ -60,6 +68,11 @@ More info here: https://ctrf.io/docs/schema/examples
60
68
  "start": 1706644023,
61
69
  "stop": 1706644043
62
70
  },
71
+ "environment": {
72
+ "buildName": "Pytest JSON CTRF Report",
73
+ "buildNumber": "000",
74
+ "buildUrl": "https://ctrf.io"
75
+ },
63
76
  "tests": [
64
77
  {
65
78
  "name": "User should be able to login",
@@ -100,3 +113,4 @@ The `pytest_runtest_logreport` hook in the controller node is used to collect th
100
113
  ### Roadmap
101
114
  - Add screenshots handling
102
115
  - Add hooks for the report extension
116
+ - [ctrf-slack-test-reporter-url]: https://github.com/ctrf-io/slack-test-reporter