orangebeard-pytest 0.1.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.
@@ -0,0 +1,177 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
@@ -0,0 +1,158 @@
1
+ Metadata-Version: 2.4
2
+ Name: orangebeard-pytest
3
+ Version: 0.1.0
4
+ Summary: Orangebeard reporting plugin for pytest (including pytest-playwright)
5
+ Author-email: Orangebeard <info@orangebeard.io>
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/orangebeard-io/pytest-listener
8
+ Project-URL: Bug Tracker, https://github.com/orangebeard-io/pytest-listener/issues
9
+ Keywords: pytest,orangebeard,test reporting,playwright
10
+ Classifier: Framework :: Pytest
11
+ Classifier: Programming Language :: Python :: 3
12
+ Classifier: Programming Language :: Python :: 3.10
13
+ Classifier: Programming Language :: Python :: 3.11
14
+ Classifier: Programming Language :: Python :: 3.12
15
+ Classifier: Programming Language :: Python :: 3.13
16
+ Classifier: Operating System :: OS Independent
17
+ Classifier: Topic :: Software Development :: Testing
18
+ Requires-Python: >=3.10
19
+ Description-Content-Type: text/markdown
20
+ License-File: LICENSE
21
+ Requires-Dist: pytest>=7.4
22
+ Requires-Dist: orangebeard-client>=2.8.0
23
+ Provides-Extra: test
24
+ Requires-Dist: pytest-playwright>=0.5; extra == "test"
25
+ Dynamic: license-file
26
+
27
+ # orangebeard-pytest
28
+
29
+ [Orangebeard](https://orangebeard.io) reporting plugin for [pytest](https://pytest.org), including
30
+ [pytest-playwright](https://github.com/microsoft/playwright-pytest).
31
+
32
+ * Suites, tests and steps: directories, modules and classes become nested suites; every test has `setup`, `call` and
33
+ `teardown` steps, fixtures become sub steps, and you can add your own nested steps.
34
+ * Logs: `logging` records, captured stdout/stderr, failure details, skip and xfail reasons.
35
+ * Attachments: anything you attach, plus the screenshots, traces and videos pytest-playwright produces.
36
+ * Never gets in the way: when Orangebeard is not configured the plugin does nothing, and reporting problems never
37
+ fail your tests.
38
+
39
+ ## Install
40
+
41
+ ```shell
42
+ pip install orangebeard-pytest
43
+ ```
44
+
45
+ The plugin is picked up automatically by pytest (entry point `pytest11`).
46
+
47
+ ## Configure
48
+
49
+ Configuration is shared with the other Orangebeard listeners. Environment variables or an `orangebeard.json`
50
+ (searched from the pytest rootdir upwards):
51
+
52
+ ```json
53
+ {
54
+ "endpoint": "https://app.orangebeard.io/{your-organization}",
55
+ "token": "00000000-0000-0000-0000-000000000000",
56
+ "project": "my-project",
57
+ "testset": "nightly",
58
+ "description": "Nightly regression",
59
+ "attributes": [{"key": "env", "value": "acceptance"}, {"value": "smoke"}]
60
+ }
61
+ ```
62
+
63
+ | Setting | Environment variable | pytest option / ini |
64
+ |------------------|-------------------------|-------------------------------------------|
65
+ | Endpoint | `ORANGEBEARD_ENDPOINT` | `--ob-endpoint` |
66
+ | Access token | `ORANGEBEARD_TOKEN` | (environment or `orangebeard.json` only) |
67
+ | Project | `ORANGEBEARD_PROJECT` | `--ob-project`, `orangebeard_project` |
68
+ | Test set | `ORANGEBEARD_TESTSET` | `--ob-testset`, `orangebeard_testset` |
69
+ | Description | `ORANGEBEARD_DESCRIPTION` | `--ob-description`, `orangebeard_description` |
70
+ | Attributes | `ORANGEBEARD_ATTRIBUTES` (`key:value;tag`) | `--ob-attribute key:value` (repeatable) |
71
+ | Existing run | `ORANGEBEARD_TESTRUN_UUID` | (report into an announced run; finish it with the Orangebeard CLI) |
72
+
73
+ Precedence: command line, then ini file, then environment / `orangebeard.json`. The test set defaults to the name of
74
+ the rootdir. Reporting is active as soon as endpoint, token and project are known.
75
+
76
+ Other options:
77
+
78
+ | Option | Meaning |
79
+ |-----------------------------------------|-------------------------------------------------------------------|
80
+ | `--orangebeard` | Fail with a clear error when the configuration is incomplete |
81
+ | `--ob-no-report` | Switch reporting off |
82
+ | `orangebeard_log_level` (default INFO) | Minimum `logging` level that is reported |
83
+ | `orangebeard_report_fixtures` | `user` (default), `all` or `none`: fixtures reported as steps |
84
+ | `orangebeard_max_attachment_mb` (50) | Larger attachments are skipped (with a warning log) |
85
+ | `orangebeard_watch_dirs` | Extra directories; files a test creates there are attached |
86
+
87
+ ## Steps, logs and attachments in your tests
88
+
89
+ ```python
90
+ import orangebeard_pytest as ob
91
+
92
+ def test_checkout(page):
93
+ with ob.step("Add item to cart"):
94
+ page.click("#add")
95
+ with ob.step("Verify badge"):
96
+ assert page.inner_text("#badge") == "1"
97
+ ob.log("cart looks fine", level="info")
98
+ ob.attach(b"{...}", name="cart.json") # bytes need a name
99
+ ob.attach("reports/summary.html") # or a path
100
+
101
+ @ob.step("Log in") # also usable as a decorator
102
+ def login(page): ...
103
+ ```
104
+
105
+ The same functions are available through the `orangebeard` fixture. Outside an Orangebeard run they do nothing, so
106
+ your tests also work without the plugin configured.
107
+
108
+ ## Playwright
109
+
110
+ Nothing to configure. Everything pytest-playwright writes to its `--output` directory while a test runs (screenshots,
111
+ `trace.zip`, videos) is attached to that test, honouring `--screenshot`, `--tracing` and `--video`:
112
+
113
+ ```shell
114
+ pytest --screenshot only-on-failure --tracing retain-on-failure --video retain-on-failure
115
+ ```
116
+
117
+ Open a downloaded trace with `playwright show-trace trace.zip`.
118
+
119
+ ## How it is reported
120
+
121
+ ```
122
+ suite tests (directory)
123
+ └ suite test_cart.py (module)
124
+ └ suite TestCart (class)
125
+ └ test test_checkout[chromium]
126
+ ├ step setup
127
+ │ └ step fixture: my_database
128
+ ├ step call
129
+ │ └ step Add item to cart
130
+ │ └ step Verify badge
131
+ └ step teardown
132
+ ```
133
+
134
+ A test fails on any setup error, test failure, teardown error or strict xpass. Skipped and xfailed tests are
135
+ `SKIPPED`.
136
+
137
+ ## Limitations
138
+
139
+ * `pytest-xdist` (`-n`) is not supported yet; reporting is disabled with a warning when it is used.
140
+ * Fixture finalizers are not reported as separate steps; their output ends up in the `teardown` step.
141
+ * While a phase runs the root logger level is lowered to `orangebeard_log_level` so records reach the reporter.
142
+
143
+ ## Development
144
+
145
+ ```shell
146
+ pip install -e ".[test]"
147
+ python -m pytest
148
+ ```
149
+
150
+ The Playwright tests need a browser: `playwright install chromium`.
151
+
152
+ The suite reports itself to Orangebeard (`orangebeard.json`: project `listeners`) when `ORANGEBEARD_TOKEN` is set,
153
+ locally via a git-ignored `.env` (see `.env.example`), in GitHub Actions via the `ORANGEBEARD_TOKEN` secret.
154
+ Without a token nothing is reported.
155
+
156
+ ## License
157
+
158
+ Apache-2.0
@@ -0,0 +1,132 @@
1
+ # orangebeard-pytest
2
+
3
+ [Orangebeard](https://orangebeard.io) reporting plugin for [pytest](https://pytest.org), including
4
+ [pytest-playwright](https://github.com/microsoft/playwright-pytest).
5
+
6
+ * Suites, tests and steps: directories, modules and classes become nested suites; every test has `setup`, `call` and
7
+ `teardown` steps, fixtures become sub steps, and you can add your own nested steps.
8
+ * Logs: `logging` records, captured stdout/stderr, failure details, skip and xfail reasons.
9
+ * Attachments: anything you attach, plus the screenshots, traces and videos pytest-playwright produces.
10
+ * Never gets in the way: when Orangebeard is not configured the plugin does nothing, and reporting problems never
11
+ fail your tests.
12
+
13
+ ## Install
14
+
15
+ ```shell
16
+ pip install orangebeard-pytest
17
+ ```
18
+
19
+ The plugin is picked up automatically by pytest (entry point `pytest11`).
20
+
21
+ ## Configure
22
+
23
+ Configuration is shared with the other Orangebeard listeners. Environment variables or an `orangebeard.json`
24
+ (searched from the pytest rootdir upwards):
25
+
26
+ ```json
27
+ {
28
+ "endpoint": "https://app.orangebeard.io/{your-organization}",
29
+ "token": "00000000-0000-0000-0000-000000000000",
30
+ "project": "my-project",
31
+ "testset": "nightly",
32
+ "description": "Nightly regression",
33
+ "attributes": [{"key": "env", "value": "acceptance"}, {"value": "smoke"}]
34
+ }
35
+ ```
36
+
37
+ | Setting | Environment variable | pytest option / ini |
38
+ |------------------|-------------------------|-------------------------------------------|
39
+ | Endpoint | `ORANGEBEARD_ENDPOINT` | `--ob-endpoint` |
40
+ | Access token | `ORANGEBEARD_TOKEN` | (environment or `orangebeard.json` only) |
41
+ | Project | `ORANGEBEARD_PROJECT` | `--ob-project`, `orangebeard_project` |
42
+ | Test set | `ORANGEBEARD_TESTSET` | `--ob-testset`, `orangebeard_testset` |
43
+ | Description | `ORANGEBEARD_DESCRIPTION` | `--ob-description`, `orangebeard_description` |
44
+ | Attributes | `ORANGEBEARD_ATTRIBUTES` (`key:value;tag`) | `--ob-attribute key:value` (repeatable) |
45
+ | Existing run | `ORANGEBEARD_TESTRUN_UUID` | (report into an announced run; finish it with the Orangebeard CLI) |
46
+
47
+ Precedence: command line, then ini file, then environment / `orangebeard.json`. The test set defaults to the name of
48
+ the rootdir. Reporting is active as soon as endpoint, token and project are known.
49
+
50
+ Other options:
51
+
52
+ | Option | Meaning |
53
+ |-----------------------------------------|-------------------------------------------------------------------|
54
+ | `--orangebeard` | Fail with a clear error when the configuration is incomplete |
55
+ | `--ob-no-report` | Switch reporting off |
56
+ | `orangebeard_log_level` (default INFO) | Minimum `logging` level that is reported |
57
+ | `orangebeard_report_fixtures` | `user` (default), `all` or `none`: fixtures reported as steps |
58
+ | `orangebeard_max_attachment_mb` (50) | Larger attachments are skipped (with a warning log) |
59
+ | `orangebeard_watch_dirs` | Extra directories; files a test creates there are attached |
60
+
61
+ ## Steps, logs and attachments in your tests
62
+
63
+ ```python
64
+ import orangebeard_pytest as ob
65
+
66
+ def test_checkout(page):
67
+ with ob.step("Add item to cart"):
68
+ page.click("#add")
69
+ with ob.step("Verify badge"):
70
+ assert page.inner_text("#badge") == "1"
71
+ ob.log("cart looks fine", level="info")
72
+ ob.attach(b"{...}", name="cart.json") # bytes need a name
73
+ ob.attach("reports/summary.html") # or a path
74
+
75
+ @ob.step("Log in") # also usable as a decorator
76
+ def login(page): ...
77
+ ```
78
+
79
+ The same functions are available through the `orangebeard` fixture. Outside an Orangebeard run they do nothing, so
80
+ your tests also work without the plugin configured.
81
+
82
+ ## Playwright
83
+
84
+ Nothing to configure. Everything pytest-playwright writes to its `--output` directory while a test runs (screenshots,
85
+ `trace.zip`, videos) is attached to that test, honouring `--screenshot`, `--tracing` and `--video`:
86
+
87
+ ```shell
88
+ pytest --screenshot only-on-failure --tracing retain-on-failure --video retain-on-failure
89
+ ```
90
+
91
+ Open a downloaded trace with `playwright show-trace trace.zip`.
92
+
93
+ ## How it is reported
94
+
95
+ ```
96
+ suite tests (directory)
97
+ └ suite test_cart.py (module)
98
+ └ suite TestCart (class)
99
+ └ test test_checkout[chromium]
100
+ ├ step setup
101
+ │ └ step fixture: my_database
102
+ ├ step call
103
+ │ └ step Add item to cart
104
+ │ └ step Verify badge
105
+ └ step teardown
106
+ ```
107
+
108
+ A test fails on any setup error, test failure, teardown error or strict xpass. Skipped and xfailed tests are
109
+ `SKIPPED`.
110
+
111
+ ## Limitations
112
+
113
+ * `pytest-xdist` (`-n`) is not supported yet; reporting is disabled with a warning when it is used.
114
+ * Fixture finalizers are not reported as separate steps; their output ends up in the `teardown` step.
115
+ * While a phase runs the root logger level is lowered to `orangebeard_log_level` so records reach the reporter.
116
+
117
+ ## Development
118
+
119
+ ```shell
120
+ pip install -e ".[test]"
121
+ python -m pytest
122
+ ```
123
+
124
+ The Playwright tests need a browser: `playwright install chromium`.
125
+
126
+ The suite reports itself to Orangebeard (`orangebeard.json`: project `listeners`) when `ORANGEBEARD_TOKEN` is set,
127
+ locally via a git-ignored `.env` (see `.env.example`), in GitHub Actions via the `ORANGEBEARD_TOKEN` secret.
128
+ Without a token nothing is reported.
129
+
130
+ ## License
131
+
132
+ Apache-2.0
@@ -0,0 +1,50 @@
1
+ [build-system]
2
+ requires = ["setuptools>=77.0"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "orangebeard-pytest"
7
+ version = "0.1.0"
8
+ description = "Orangebeard reporting plugin for pytest (including pytest-playwright)"
9
+ readme = "README.md"
10
+ requires-python = ">=3.10"
11
+ license = "Apache-2.0"
12
+ license-files = ["LICENSE"]
13
+ keywords = ["pytest", "orangebeard", "test reporting", "playwright"]
14
+ classifiers = [
15
+ "Framework :: Pytest",
16
+ "Programming Language :: Python :: 3",
17
+ "Programming Language :: Python :: 3.10",
18
+ "Programming Language :: Python :: 3.11",
19
+ "Programming Language :: Python :: 3.12",
20
+ "Programming Language :: Python :: 3.13",
21
+ "Operating System :: OS Independent",
22
+ "Topic :: Software Development :: Testing",
23
+ ]
24
+ dependencies = [
25
+ "pytest>=7.4",
26
+ "orangebeard-client>=2.8.0",
27
+ ]
28
+
29
+ [[project.authors]]
30
+ name = "Orangebeard"
31
+ email = "info@orangebeard.io"
32
+
33
+ [project.optional-dependencies]
34
+ test = ["pytest-playwright>=0.5"]
35
+
36
+ [project.entry-points.pytest11]
37
+ orangebeard = "orangebeard_pytest.plugin"
38
+
39
+ [project.urls]
40
+ Homepage = "https://github.com/orangebeard-io/pytest-listener"
41
+ "Bug Tracker" = "https://github.com/orangebeard-io/pytest-listener/issues"
42
+
43
+ [tool.setuptools.packages.find]
44
+ where = ["src"]
45
+
46
+ [tool.pytest.ini_options]
47
+ testpaths = ["tests"]
48
+ # Do not share pytest-playwright between the outer run and the in-process inner runs of pytester.
49
+ addopts = "-p no:playwright"
50
+ markers = ["playwright_browser: needs an installed Playwright browser (run `playwright install chromium`)"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,4 @@
1
+ """Orangebeard reporting for pytest."""
2
+ from orangebeard_pytest.steps import attach, log, step
3
+
4
+ __all__ = ['step', 'log', 'attach']
@@ -0,0 +1,42 @@
1
+ """Find files (screenshots, traces, videos...) that a test produced in watched directories."""
2
+ import os
3
+ from pathlib import Path
4
+ from typing import Dict, List, Tuple
5
+
6
+ Snapshot = Dict[Path, Tuple[int, int]]
7
+
8
+
9
+ class DirectoryWatcher:
10
+ def __init__(self, root: Path):
11
+ self.root = Path(root)
12
+
13
+ def snapshot(self) -> Snapshot:
14
+ found: Snapshot = {}
15
+ if not self.root.is_dir():
16
+ return found
17
+ for folder, _, files in os.walk(self.root):
18
+ for name in files:
19
+ path = Path(folder) / name
20
+ try:
21
+ stat = path.stat()
22
+ except OSError:
23
+ continue
24
+ found[path] = (stat.st_mtime_ns, stat.st_size)
25
+ return found
26
+
27
+ def new_files(self, before: Snapshot) -> List[Path]:
28
+ """Files that are new or modified since `before` was taken."""
29
+ return sorted(path for path, signature in self.snapshot().items() if before.get(path) != signature)
30
+
31
+
32
+ def describe(path: Path) -> str:
33
+ """Human friendly label for an artifact; Playwright files are recognisable."""
34
+ name = Path(path).name
35
+ suffix = Path(path).suffix.lower()
36
+ if name == 'trace.zip':
37
+ return f'{name} (Playwright trace; view with: playwright show-trace {name})'
38
+ if suffix in ('.webm', '.mp4'):
39
+ return f'Video recording: {name}'
40
+ if suffix in ('.png', '.jpg', '.jpeg') and name.startswith('test-'):
41
+ return f'Screenshot: {name}'
42
+ return name