pytestomatio 2.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.
- pytestomatio-2.2.1/LICENSE +21 -0
- pytestomatio-2.2.1/PKG-INFO +225 -0
- pytestomatio-2.2.1/README.md +204 -0
- pytestomatio-2.2.1/pyproject.toml +45 -0
- pytestomatio-2.2.1/pytestomatio/__init__.py +0 -0
- pytestomatio-2.2.1/pytestomatio/code_collector.py +15 -0
- pytestomatio-2.2.1/pytestomatio/connector.py +189 -0
- pytestomatio-2.2.1/pytestomatio/decorator_updater.py +81 -0
- pytestomatio-2.2.1/pytestomatio/helper.py +82 -0
- pytestomatio-2.2.1/pytestomatio/main.py +246 -0
- pytestomatio-2.2.1/pytestomatio/s3_connector.py +61 -0
- pytestomatio-2.2.1/pytestomatio/testItem.py +144 -0
- pytestomatio-2.2.1/pytestomatio/testRunConfig.py +48 -0
- pytestomatio-2.2.1/pytestomatio/testomat_item.py +18 -0
- pytestomatio-2.2.1/pytestomatio/testomatio.py +31 -0
- pytestomatio-2.2.1/pytestomatio.egg-info/PKG-INFO +225 -0
- pytestomatio-2.2.1/pytestomatio.egg-info/SOURCES.txt +28 -0
- pytestomatio-2.2.1/pytestomatio.egg-info/dependency_links.txt +1 -0
- pytestomatio-2.2.1/pytestomatio.egg-info/entry_points.txt +2 -0
- pytestomatio-2.2.1/pytestomatio.egg-info/requires.txt +5 -0
- pytestomatio-2.2.1/pytestomatio.egg-info/top_level.txt +3 -0
- pytestomatio-2.2.1/setup.cfg +4 -0
- pytestomatio-2.2.1/tests/sub/__init__.py +0 -0
- pytestomatio-2.2.1/tests/sub/sub_mob/__init__.py +0 -0
- pytestomatio-2.2.1/tests/sub/sub_mob/sub_sub_class_test.py +17 -0
- pytestomatio-2.2.1/tests/sub/sub_mob/sub_sub_test.py +25 -0
- pytestomatio-2.2.1/tests/sub/test_class_sub.py +17 -0
- pytestomatio-2.2.1/tests/sub/test_sub.py +25 -0
- pytestomatio-2.2.1/tests/test_class_root.py +17 -0
- pytestomatio-2.2.1/tests/test_root.py +43 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 pytest-analyzer
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: pytestomatio
|
|
3
|
+
Version: 2.2.1
|
|
4
|
+
Summary: Pytest plugin to sync test with testomat.io
|
|
5
|
+
Author: Oleksii Ostapov, TikoQA
|
|
6
|
+
Project-URL: Testomat.io, https://testomat.io/
|
|
7
|
+
Project-URL: Homepage, https://github.com/tikolakin/pytestomatio
|
|
8
|
+
Project-URL: Bug Tracker, https://github.com/tikolakin/pytestomatio/issues
|
|
9
|
+
Classifier: Framework :: Pytest
|
|
10
|
+
Classifier: Programming Language :: Python :: 3
|
|
11
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
12
|
+
Classifier: Operating System :: OS Independent
|
|
13
|
+
Requires-Python: >=3.10
|
|
14
|
+
Description-Content-Type: text/markdown
|
|
15
|
+
License-File: LICENSE
|
|
16
|
+
Requires-Dist: requests>=2.29.0
|
|
17
|
+
Requires-Dist: pytest<8.0.0,>=7.3.1
|
|
18
|
+
Requires-Dist: boto3>=1.28.28
|
|
19
|
+
Requires-Dist: libcst==1.1.0
|
|
20
|
+
Requires-Dist: commitizen>=3.18.1
|
|
21
|
+
|
|
22
|
+
[](https://github.com/support-ukraine/support-ukraine)
|
|
23
|
+
|
|
24
|
+
# testomat.io plugin for pytest
|
|
25
|
+
|
|
26
|
+
## uses testomat.io API:
|
|
27
|
+
|
|
28
|
+
- https://testomatio.github.io/check-tests/
|
|
29
|
+
- https://testomatio.github.io/reporter/
|
|
30
|
+
|
|
31
|
+
## Installation
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
pip install git+https://github.com/tikolakin/pytestomatio.git@1.7#egg=pytestomatio
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## configuration
|
|
38
|
+
|
|
39
|
+
Create environment variable `TESTOMATIO` and set your testomat.io API key.
|
|
40
|
+
Linux:
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
export TESTOMATIO=<key>
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Windows (cmd):
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
set TESTOMATIO=<key>
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### Run groups parameter
|
|
53
|
+
There is environment variable `TESTOMATIO_RUNGROUP_TITLE` that can be used to specify run tests with specific group title.
|
|
54
|
+
|
|
55
|
+
### pytest.ini
|
|
56
|
+
In case you are using private testomat.io service, create `pytest.ini` file in your project root directory. Specify
|
|
57
|
+
testomat.io url in it
|
|
58
|
+
|
|
59
|
+
```ini
|
|
60
|
+
[pytest]
|
|
61
|
+
testomatio_url = https://app.testomat.io
|
|
62
|
+
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## Usage
|
|
66
|
+
|
|
67
|
+
Synchronize tests to testomat.io and get back test id.
|
|
68
|
+
Tests will not be executed
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
pytest --testomatio sync
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Remove all test ids from source code. Tests will not be executed
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
pytest --testomatio remove
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Run pytest and send test results into testomat.io.
|
|
81
|
+
Test can be sent to testomat.io without ids in your test code. If testomat.io failed to match tests by title, it will create
|
|
82
|
+
new tests for the run
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
pytest --testomatio report
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Run pytest with debug parameter to get test data collected in metadata.json file
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
pytest --testomatio debug
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### Submitting Test Run Environment
|
|
95
|
+
|
|
96
|
+
to configure test environment, you can use additional option:
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
pytest --testomatio report --testRunEnv "windows11,chrome,1920x1080"
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
Environment values are comma separated, please use double quotation.
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
### Submitting Test Artifacts
|
|
106
|
+
|
|
107
|
+
testomat.io does not store any screenshots, logs or other artifacts.
|
|
108
|
+
|
|
109
|
+
In order to manage them it is advised to use S3 Buckets (GCP Storage).
|
|
110
|
+
https://docs.testomat.io/usage/test-artifacts/
|
|
111
|
+
|
|
112
|
+
Analyser needs to be aware of the cloud storage credentials.
|
|
113
|
+
There are two options:
|
|
114
|
+
1. Enable **Share credentials with testomat.io Reporter** option in testomat.io Settings -> Artifacts.
|
|
115
|
+
2. Use environment variables `ACCESS_KEY_ID, SECRET_ACCESS_KEY, ENDPOINT, BUCKET`
|
|
116
|
+
|
|
117
|
+
You would need to decide when you want to upload your test artifacts to cloud storage
|
|
118
|
+
|
|
119
|
+
1) Upload page screenshot when test fails, using fixtures [reference](https://docs.pytest.org/en/latest/example/simple.html#making-test-result-information-available-in-fixtures)
|
|
120
|
+
|
|
121
|
+
```python
|
|
122
|
+
# content of conftest.py
|
|
123
|
+
import pytest
|
|
124
|
+
from typing import Dict
|
|
125
|
+
from pytest import StashKey, CollectReport
|
|
126
|
+
from playwright.sync_api import Page
|
|
127
|
+
|
|
128
|
+
phase_report_key = StashKey[Dict[str, CollectReport]]()
|
|
129
|
+
|
|
130
|
+
@pytest.hookimpl(wrapper=True, tryfirst=True)
|
|
131
|
+
def pytest_runtest_makereport(item, call):
|
|
132
|
+
rep = yield
|
|
133
|
+
item.stash.setdefault(phase_report_key, {})[rep.when] = rep
|
|
134
|
+
return rep
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
@pytest.fixture(scope="function")
|
|
138
|
+
def handle_artifacts(page: Page, request):
|
|
139
|
+
yield
|
|
140
|
+
report = request.node.stash[phase_report_key]
|
|
141
|
+
if ("call" not in report) or report["setup"].failed or report["call"].failed:
|
|
142
|
+
random_string = ''.join(random.choices(string.ascii_letters + string.digits, k=8))
|
|
143
|
+
|
|
144
|
+
filename = f"{random_string}.png"
|
|
145
|
+
screenshot_path = os.path.join(artifacts_dir, filename)
|
|
146
|
+
page.screenshot(path=screenshot_path)
|
|
147
|
+
# file_path - required, path to file to be uploaded
|
|
148
|
+
# file_bytes - required, bytes of the file to be uploaded
|
|
149
|
+
# key - required, file name in the s3 bucket
|
|
150
|
+
# bucket_name - optional,name of the bucket to upload file to. Default value is taken from testomat.io
|
|
151
|
+
artifact_url = pytest.testomatio.upload_file(screenshot_path, filename)
|
|
152
|
+
# or
|
|
153
|
+
# artifact_url = pytest.testomatio.upload_file_object(file_bytes, key, bucket_name)
|
|
154
|
+
pytest.testomatio.add_artifacts(request.node, [artifact_url])
|
|
155
|
+
page.close()
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
⚠️ Please take into account s3_connector available only after **pytest_collection_modifyitems()** hook is executed.
|
|
159
|
+
|
|
160
|
+
2) If you prefer to use pytest hooks - add `pytest_runtest_makereport` hook in your `conftest.py` file.
|
|
161
|
+
|
|
162
|
+
```python
|
|
163
|
+
def pytest_runtest_makereport(item, call):
|
|
164
|
+
artifact_url = pytest.testomatio.upload_file(screenshot_path, filename)
|
|
165
|
+
pytest.testomatio.add_artifacts([artifact_url])
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
### Clarifications
|
|
169
|
+
|
|
170
|
+
- tests can be synced even without `@patest.mark.testomatio('@T96c700e6')` decorator.
|
|
171
|
+
- test title in testomat.io == test name in pytest
|
|
172
|
+
- test suit title in testomat.io == test file name in pytest
|
|
173
|
+
|
|
174
|
+
## Example of test
|
|
175
|
+
|
|
176
|
+
To make the experience more consistent, it uses standard pytest markers.
|
|
177
|
+
testomat.io test id is a string value that starts with `@T` and has 8 symbols after.
|
|
178
|
+
|
|
179
|
+
```python
|
|
180
|
+
import pytest
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
@pytest.mark.testomatio('@T96c700e6')
|
|
184
|
+
def test_example():
|
|
185
|
+
assert 2 + 2 == 4
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
### Compatibility table with [Testomatio check-tests](https://github.com/testomatio/check-tests)
|
|
189
|
+
|
|
190
|
+
| Action | Compatibility | Method |
|
|
191
|
+
|--------|--------|-------|
|
|
192
|
+
| Importing test into testomat.io | complete | `pytest --testomatio sync` |
|
|
193
|
+
| Exclude hook code of a test | N/A | N/A |
|
|
194
|
+
| Include line number code of a test | N/A | N/A |
|
|
195
|
+
| Import Parametrized Tests | complete | default behaviour |
|
|
196
|
+
| Disable Detached Tests | complete | `pytest --testomatio sync --no-detached` |
|
|
197
|
+
| Synchronous Import | complete | default behaviour |
|
|
198
|
+
| Auto-assign Test IDs in Source Code | complete | default behaviour |
|
|
199
|
+
| Keep Test IDs Between Projects | complete | `pytest --testomatio sync --create` |
|
|
200
|
+
| Clean Test IDs | complete | `pytest --testomatio remove` |
|
|
201
|
+
| Import Into a Branch | N/A | N/A |
|
|
202
|
+
| Keep Structure of Source Code | complete | `pytest --testomatio sync --keep-structure` |
|
|
203
|
+
| Delete Empty Suites | complete | `pytest --testomatio sync --no-empty` |
|
|
204
|
+
| Import Into a Specific Folder | complete | `pytest --testomatio --directory "Windows\smoke"` |
|
|
205
|
+
| Debugging | parity | `pytest --testomatio debug` |
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
## Test
|
|
209
|
+
- import into empty project
|
|
210
|
+
- updated test - (resync)
|
|
211
|
+
- test run
|
|
212
|
+
- test run into a folder
|
|
213
|
+
- test run labels, tags
|
|
214
|
+
|
|
215
|
+
## TODO
|
|
216
|
+
- Fix test duration
|
|
217
|
+
- Require more back references from testomatio
|
|
218
|
+
- pytest.skip should behave as @pytest.mark.skip
|
|
219
|
+
- Refactor test run and make run url available
|
|
220
|
+
|
|
221
|
+
## Contribution
|
|
222
|
+
1. `pip install -e .`
|
|
223
|
+
2. `cz commit`
|
|
224
|
+
3. `cz bump`
|
|
225
|
+
4. `git push remoteName branchName --tags`
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
[](https://github.com/support-ukraine/support-ukraine)
|
|
2
|
+
|
|
3
|
+
# testomat.io plugin for pytest
|
|
4
|
+
|
|
5
|
+
## uses testomat.io API:
|
|
6
|
+
|
|
7
|
+
- https://testomatio.github.io/check-tests/
|
|
8
|
+
- https://testomatio.github.io/reporter/
|
|
9
|
+
|
|
10
|
+
## Installation
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
pip install git+https://github.com/tikolakin/pytestomatio.git@1.7#egg=pytestomatio
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## configuration
|
|
17
|
+
|
|
18
|
+
Create environment variable `TESTOMATIO` and set your testomat.io API key.
|
|
19
|
+
Linux:
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
export TESTOMATIO=<key>
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Windows (cmd):
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
set TESTOMATIO=<key>
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### Run groups parameter
|
|
32
|
+
There is environment variable `TESTOMATIO_RUNGROUP_TITLE` that can be used to specify run tests with specific group title.
|
|
33
|
+
|
|
34
|
+
### pytest.ini
|
|
35
|
+
In case you are using private testomat.io service, create `pytest.ini` file in your project root directory. Specify
|
|
36
|
+
testomat.io url in it
|
|
37
|
+
|
|
38
|
+
```ini
|
|
39
|
+
[pytest]
|
|
40
|
+
testomatio_url = https://app.testomat.io
|
|
41
|
+
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Usage
|
|
45
|
+
|
|
46
|
+
Synchronize tests to testomat.io and get back test id.
|
|
47
|
+
Tests will not be executed
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
pytest --testomatio sync
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Remove all test ids from source code. Tests will not be executed
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
pytest --testomatio remove
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Run pytest and send test results into testomat.io.
|
|
60
|
+
Test can be sent to testomat.io without ids in your test code. If testomat.io failed to match tests by title, it will create
|
|
61
|
+
new tests for the run
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
pytest --testomatio report
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
Run pytest with debug parameter to get test data collected in metadata.json file
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
pytest --testomatio debug
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### Submitting Test Run Environment
|
|
74
|
+
|
|
75
|
+
to configure test environment, you can use additional option:
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
pytest --testomatio report --testRunEnv "windows11,chrome,1920x1080"
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
Environment values are comma separated, please use double quotation.
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
### Submitting Test Artifacts
|
|
85
|
+
|
|
86
|
+
testomat.io does not store any screenshots, logs or other artifacts.
|
|
87
|
+
|
|
88
|
+
In order to manage them it is advised to use S3 Buckets (GCP Storage).
|
|
89
|
+
https://docs.testomat.io/usage/test-artifacts/
|
|
90
|
+
|
|
91
|
+
Analyser needs to be aware of the cloud storage credentials.
|
|
92
|
+
There are two options:
|
|
93
|
+
1. Enable **Share credentials with testomat.io Reporter** option in testomat.io Settings -> Artifacts.
|
|
94
|
+
2. Use environment variables `ACCESS_KEY_ID, SECRET_ACCESS_KEY, ENDPOINT, BUCKET`
|
|
95
|
+
|
|
96
|
+
You would need to decide when you want to upload your test artifacts to cloud storage
|
|
97
|
+
|
|
98
|
+
1) Upload page screenshot when test fails, using fixtures [reference](https://docs.pytest.org/en/latest/example/simple.html#making-test-result-information-available-in-fixtures)
|
|
99
|
+
|
|
100
|
+
```python
|
|
101
|
+
# content of conftest.py
|
|
102
|
+
import pytest
|
|
103
|
+
from typing import Dict
|
|
104
|
+
from pytest import StashKey, CollectReport
|
|
105
|
+
from playwright.sync_api import Page
|
|
106
|
+
|
|
107
|
+
phase_report_key = StashKey[Dict[str, CollectReport]]()
|
|
108
|
+
|
|
109
|
+
@pytest.hookimpl(wrapper=True, tryfirst=True)
|
|
110
|
+
def pytest_runtest_makereport(item, call):
|
|
111
|
+
rep = yield
|
|
112
|
+
item.stash.setdefault(phase_report_key, {})[rep.when] = rep
|
|
113
|
+
return rep
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
@pytest.fixture(scope="function")
|
|
117
|
+
def handle_artifacts(page: Page, request):
|
|
118
|
+
yield
|
|
119
|
+
report = request.node.stash[phase_report_key]
|
|
120
|
+
if ("call" not in report) or report["setup"].failed or report["call"].failed:
|
|
121
|
+
random_string = ''.join(random.choices(string.ascii_letters + string.digits, k=8))
|
|
122
|
+
|
|
123
|
+
filename = f"{random_string}.png"
|
|
124
|
+
screenshot_path = os.path.join(artifacts_dir, filename)
|
|
125
|
+
page.screenshot(path=screenshot_path)
|
|
126
|
+
# file_path - required, path to file to be uploaded
|
|
127
|
+
# file_bytes - required, bytes of the file to be uploaded
|
|
128
|
+
# key - required, file name in the s3 bucket
|
|
129
|
+
# bucket_name - optional,name of the bucket to upload file to. Default value is taken from testomat.io
|
|
130
|
+
artifact_url = pytest.testomatio.upload_file(screenshot_path, filename)
|
|
131
|
+
# or
|
|
132
|
+
# artifact_url = pytest.testomatio.upload_file_object(file_bytes, key, bucket_name)
|
|
133
|
+
pytest.testomatio.add_artifacts(request.node, [artifact_url])
|
|
134
|
+
page.close()
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
⚠️ Please take into account s3_connector available only after **pytest_collection_modifyitems()** hook is executed.
|
|
138
|
+
|
|
139
|
+
2) If you prefer to use pytest hooks - add `pytest_runtest_makereport` hook in your `conftest.py` file.
|
|
140
|
+
|
|
141
|
+
```python
|
|
142
|
+
def pytest_runtest_makereport(item, call):
|
|
143
|
+
artifact_url = pytest.testomatio.upload_file(screenshot_path, filename)
|
|
144
|
+
pytest.testomatio.add_artifacts([artifact_url])
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
### Clarifications
|
|
148
|
+
|
|
149
|
+
- tests can be synced even without `@patest.mark.testomatio('@T96c700e6')` decorator.
|
|
150
|
+
- test title in testomat.io == test name in pytest
|
|
151
|
+
- test suit title in testomat.io == test file name in pytest
|
|
152
|
+
|
|
153
|
+
## Example of test
|
|
154
|
+
|
|
155
|
+
To make the experience more consistent, it uses standard pytest markers.
|
|
156
|
+
testomat.io test id is a string value that starts with `@T` and has 8 symbols after.
|
|
157
|
+
|
|
158
|
+
```python
|
|
159
|
+
import pytest
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
@pytest.mark.testomatio('@T96c700e6')
|
|
163
|
+
def test_example():
|
|
164
|
+
assert 2 + 2 == 4
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
### Compatibility table with [Testomatio check-tests](https://github.com/testomatio/check-tests)
|
|
168
|
+
|
|
169
|
+
| Action | Compatibility | Method |
|
|
170
|
+
|--------|--------|-------|
|
|
171
|
+
| Importing test into testomat.io | complete | `pytest --testomatio sync` |
|
|
172
|
+
| Exclude hook code of a test | N/A | N/A |
|
|
173
|
+
| Include line number code of a test | N/A | N/A |
|
|
174
|
+
| Import Parametrized Tests | complete | default behaviour |
|
|
175
|
+
| Disable Detached Tests | complete | `pytest --testomatio sync --no-detached` |
|
|
176
|
+
| Synchronous Import | complete | default behaviour |
|
|
177
|
+
| Auto-assign Test IDs in Source Code | complete | default behaviour |
|
|
178
|
+
| Keep Test IDs Between Projects | complete | `pytest --testomatio sync --create` |
|
|
179
|
+
| Clean Test IDs | complete | `pytest --testomatio remove` |
|
|
180
|
+
| Import Into a Branch | N/A | N/A |
|
|
181
|
+
| Keep Structure of Source Code | complete | `pytest --testomatio sync --keep-structure` |
|
|
182
|
+
| Delete Empty Suites | complete | `pytest --testomatio sync --no-empty` |
|
|
183
|
+
| Import Into a Specific Folder | complete | `pytest --testomatio --directory "Windows\smoke"` |
|
|
184
|
+
| Debugging | parity | `pytest --testomatio debug` |
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
## Test
|
|
188
|
+
- import into empty project
|
|
189
|
+
- updated test - (resync)
|
|
190
|
+
- test run
|
|
191
|
+
- test run into a folder
|
|
192
|
+
- test run labels, tags
|
|
193
|
+
|
|
194
|
+
## TODO
|
|
195
|
+
- Fix test duration
|
|
196
|
+
- Require more back references from testomatio
|
|
197
|
+
- pytest.skip should behave as @pytest.mark.skip
|
|
198
|
+
- Refactor test run and make run url available
|
|
199
|
+
|
|
200
|
+
## Contribution
|
|
201
|
+
1. `pip install -e .`
|
|
202
|
+
2. `cz commit`
|
|
203
|
+
3. `cz bump`
|
|
204
|
+
4. `git push remoteName branchName --tags`
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=65.5.1", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[tool.setuptools.packages.find]
|
|
6
|
+
exclude = [".github", "tests"]
|
|
7
|
+
|
|
8
|
+
[tool.commitizen]
|
|
9
|
+
name = "cz_conventional_commits"
|
|
10
|
+
tag_format = "$version"
|
|
11
|
+
version_scheme = "pep440"
|
|
12
|
+
version_provider = "pep621"
|
|
13
|
+
update_changelog_on_bump = true
|
|
14
|
+
[project]
|
|
15
|
+
name = "pytestomatio"
|
|
16
|
+
version = "2.2.1"
|
|
17
|
+
|
|
18
|
+
dependencies = [
|
|
19
|
+
"requests>=2.29.0",
|
|
20
|
+
"pytest<8.0.0,>=7.3.1",
|
|
21
|
+
"boto3>=1.28.28",
|
|
22
|
+
"libcst==1.1.0",
|
|
23
|
+
"commitizen>=3.18.1"]
|
|
24
|
+
|
|
25
|
+
authors = [
|
|
26
|
+
{ name = "Oleksii Ostapov" },
|
|
27
|
+
{ name = "TikoQA" },
|
|
28
|
+
]
|
|
29
|
+
description = "Pytest plugin to sync test with testomat.io"
|
|
30
|
+
readme = "README.md"
|
|
31
|
+
requires-python = ">=3.10"
|
|
32
|
+
classifiers = [
|
|
33
|
+
"Framework :: Pytest",
|
|
34
|
+
"Programming Language :: Python :: 3",
|
|
35
|
+
"License :: OSI Approved :: MIT License",
|
|
36
|
+
"Operating System :: OS Independent",
|
|
37
|
+
]
|
|
38
|
+
|
|
39
|
+
[project.urls]
|
|
40
|
+
"Testomat.io" = "https://testomat.io/"
|
|
41
|
+
"Homepage" = "https://github.com/tikolakin/pytestomatio"
|
|
42
|
+
"Bug Tracker" = "https://github.com/tikolakin/pytestomatio/issues"
|
|
43
|
+
|
|
44
|
+
[project.entry-points.pytest11]
|
|
45
|
+
pytestomatio = "pytestomatio.main"
|
|
File without changes
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import importlib.util
|
|
2
|
+
import inspect
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
def get_functions_source_by_name(abs_file_path: str, all_tests: list[str]):
|
|
6
|
+
spec = importlib.util.spec_from_file_location('name', abs_file_path)
|
|
7
|
+
module = importlib.util.module_from_spec(spec)
|
|
8
|
+
spec.loader.exec_module(module)
|
|
9
|
+
functions = inspect.getmembers(module, inspect.isfunction)
|
|
10
|
+
classes = inspect.getmembers(module, inspect.isclass)
|
|
11
|
+
for class_name, cls in classes:
|
|
12
|
+
functions += inspect.getmembers(cls, inspect.isfunction)
|
|
13
|
+
for function_name, function in functions:
|
|
14
|
+
if function_name in all_tests:
|
|
15
|
+
yield function_name, inspect.getsource(function)
|