throngtest 0.0.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.
- throngtest-0.0.1/LICENSE +131 -0
- throngtest-0.0.1/PKG-INFO +332 -0
- throngtest-0.0.1/README.md +300 -0
- throngtest-0.0.1/pyproject.toml +80 -0
- throngtest-0.0.1/setup.cfg +4 -0
- throngtest-0.0.1/tests/test_coverage.py +45 -0
- throngtest-0.0.1/tests/test_coverage_agents.py +579 -0
- throngtest-0.0.1/tests/test_distribution.py +97 -0
- throngtest-0.0.1/tests/test_fingerprints.py +127 -0
- throngtest-0.0.1/tests/test_integration.py +447 -0
- throngtest-0.0.1/tests/test_preparation.py +208 -0
- throngtest-0.0.1/tests/test_protocol.py +34 -0
- throngtest-0.0.1/tests/test_runner.py +275 -0
- throngtest-0.0.1/tests/test_settings.py +124 -0
- throngtest-0.0.1/tests/test_xdist.py +403 -0
- throngtest-0.0.1/throngtest/__init__.py +0 -0
- throngtest-0.0.1/throngtest/coverage.py +157 -0
- throngtest-0.0.1/throngtest/coverage_transport.py +93 -0
- throngtest-0.0.1/throngtest/distribution.py +54 -0
- throngtest-0.0.1/throngtest/plugin.py +56 -0
- throngtest-0.0.1/throngtest/protocol.py +60 -0
- throngtest-0.0.1/throngtest/py.typed +0 -0
- throngtest-0.0.1/throngtest/runner.py +333 -0
- throngtest-0.0.1/throngtest/settings.py +69 -0
- throngtest-0.0.1/throngtest/worker.py +171 -0
- throngtest-0.0.1/throngtest/xdist.py +86 -0
- throngtest-0.0.1/throngtest.egg-info/PKG-INFO +332 -0
- throngtest-0.0.1/throngtest.egg-info/SOURCES.txt +30 -0
- throngtest-0.0.1/throngtest.egg-info/dependency_links.txt +1 -0
- throngtest-0.0.1/throngtest.egg-info/entry_points.txt +2 -0
- throngtest-0.0.1/throngtest.egg-info/requires.txt +4 -0
- throngtest-0.0.1/throngtest.egg-info/top_level.txt +1 -0
throngtest-0.0.1/LICENSE
ADDED
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
# PolyForm Noncommercial License 1.0.0
|
|
2
|
+
|
|
3
|
+
<https://polyformproject.org/licenses/noncommercial/1.0.0>
|
|
4
|
+
|
|
5
|
+
## Acceptance
|
|
6
|
+
|
|
7
|
+
In order to get any license under these terms, you must agree
|
|
8
|
+
to them as both strict obligations and conditions to all
|
|
9
|
+
your licenses.
|
|
10
|
+
|
|
11
|
+
## Copyright License
|
|
12
|
+
|
|
13
|
+
The licensor grants you a copyright license for the
|
|
14
|
+
software to do everything you might do with the software
|
|
15
|
+
that would otherwise infringe the licensor's copyright
|
|
16
|
+
in it for any permitted purpose. However, you may
|
|
17
|
+
only distribute the software according to [Distribution
|
|
18
|
+
License](#distribution-license) and make changes or new works
|
|
19
|
+
based on the software according to [Changes and New Works
|
|
20
|
+
License](#changes-and-new-works-license).
|
|
21
|
+
|
|
22
|
+
## Distribution License
|
|
23
|
+
|
|
24
|
+
The licensor grants you an additional copyright license
|
|
25
|
+
to distribute copies of the software. Your license
|
|
26
|
+
to distribute covers distributing the software with
|
|
27
|
+
changes and new works permitted by [Changes and New Works
|
|
28
|
+
License](#changes-and-new-works-license).
|
|
29
|
+
|
|
30
|
+
## Notices
|
|
31
|
+
|
|
32
|
+
You must ensure that anyone who gets a copy of any part of
|
|
33
|
+
the software from you also gets a copy of these terms or the
|
|
34
|
+
URL for them above, as well as copies of any plain-text lines
|
|
35
|
+
beginning with `Required Notice:` that the licensor provided
|
|
36
|
+
with the software. For example:
|
|
37
|
+
|
|
38
|
+
> Required Notice: Copyright Yoyodyne, Inc. (http://example.com)
|
|
39
|
+
|
|
40
|
+
## Changes and New Works License
|
|
41
|
+
|
|
42
|
+
The licensor grants you an additional copyright license to
|
|
43
|
+
make changes and new works based on the software for any
|
|
44
|
+
permitted purpose.
|
|
45
|
+
|
|
46
|
+
## Patent License
|
|
47
|
+
|
|
48
|
+
The licensor grants you a patent license for the software that
|
|
49
|
+
covers patent claims the licensor can license, or becomes able
|
|
50
|
+
to license, that you would infringe by using the software.
|
|
51
|
+
|
|
52
|
+
## Noncommercial Purposes
|
|
53
|
+
|
|
54
|
+
Any noncommercial purpose is a permitted purpose.
|
|
55
|
+
|
|
56
|
+
## Personal Uses
|
|
57
|
+
|
|
58
|
+
Personal use for research, experiment, and testing for
|
|
59
|
+
the benefit of public knowledge, personal study, private
|
|
60
|
+
entertainment, hobby projects, amateur pursuits, or religious
|
|
61
|
+
observance, without any anticipated commercial application,
|
|
62
|
+
is use for a permitted purpose.
|
|
63
|
+
|
|
64
|
+
## Noncommercial Organizations
|
|
65
|
+
|
|
66
|
+
Use by any charitable organization, educational institution,
|
|
67
|
+
public research organization, public safety or health
|
|
68
|
+
organization, environmental protection organization,
|
|
69
|
+
or government institution is use for a permitted purpose
|
|
70
|
+
regardless of the source of funding or obligations resulting
|
|
71
|
+
from the funding.
|
|
72
|
+
|
|
73
|
+
## Fair Use
|
|
74
|
+
|
|
75
|
+
You may have "fair use" rights for the software under the
|
|
76
|
+
law. These terms do not limit them.
|
|
77
|
+
|
|
78
|
+
## No Other Rights
|
|
79
|
+
|
|
80
|
+
These terms do not allow you to sublicense or transfer any of
|
|
81
|
+
your licenses to anyone else, or prevent the licensor from
|
|
82
|
+
granting licenses to anyone else. These terms do not imply
|
|
83
|
+
any other licenses.
|
|
84
|
+
|
|
85
|
+
## Patent Defense
|
|
86
|
+
|
|
87
|
+
If you make any written claim that the software infringes or
|
|
88
|
+
contributes to infringement of any patent, your patent license
|
|
89
|
+
for the software granted under these terms ends immediately. If
|
|
90
|
+
your company makes such a claim, your patent license ends
|
|
91
|
+
immediately for work on behalf of your company.
|
|
92
|
+
|
|
93
|
+
## Violations
|
|
94
|
+
|
|
95
|
+
The first time you are notified in writing that you have
|
|
96
|
+
violated any of these terms, or done anything with the software
|
|
97
|
+
not covered by your licenses, your licenses can nonetheless
|
|
98
|
+
continue if you come into full compliance with these terms,
|
|
99
|
+
and take practical steps to correct past violations, within
|
|
100
|
+
32 days of receiving notice. Otherwise, all your licenses
|
|
101
|
+
end immediately.
|
|
102
|
+
|
|
103
|
+
## No Liability
|
|
104
|
+
|
|
105
|
+
***As far as the law allows, the software comes as is, without
|
|
106
|
+
any warranty or condition, and the licensor will not be liable
|
|
107
|
+
to you for any damages arising out of these terms or the use
|
|
108
|
+
or nature of the software, under any kind of legal claim.***
|
|
109
|
+
|
|
110
|
+
## Definitions
|
|
111
|
+
|
|
112
|
+
The **licensor** is the individual or entity offering these
|
|
113
|
+
terms, and the **software** is the software the licensor makes
|
|
114
|
+
available under these terms.
|
|
115
|
+
|
|
116
|
+
**You** refers to the individual or entity agreeing to these
|
|
117
|
+
terms.
|
|
118
|
+
|
|
119
|
+
**Your company** is any legal entity, sole proprietorship,
|
|
120
|
+
or other kind of organization that you work for, plus all
|
|
121
|
+
organizations that have control over, are under the control of,
|
|
122
|
+
or are under common control with that organization. **Control**
|
|
123
|
+
means ownership of substantially all the assets of an entity,
|
|
124
|
+
or the power to direct its management and policies by vote,
|
|
125
|
+
contract, or otherwise. Control can be direct or indirect.
|
|
126
|
+
|
|
127
|
+
**Your licenses** are all the licenses granted to you for the
|
|
128
|
+
software under these terms.
|
|
129
|
+
|
|
130
|
+
**Use** means anything you do with the software requiring one
|
|
131
|
+
of your licenses.
|
|
@@ -0,0 +1,332 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: throngtest
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: Distributed pytest execution in isolated environments
|
|
5
|
+
Author-email: Evgeniy Blinov <zheni-b@yandex.ru>
|
|
6
|
+
Project-URL: Source, https://github.com/mutating/throngtest
|
|
7
|
+
Project-URL: Tracker, https://github.com/mutating/throngtest/issues
|
|
8
|
+
Keywords: pytest
|
|
9
|
+
Classifier: Operating System :: OS Independent
|
|
10
|
+
Classifier: Operating System :: MacOS :: MacOS X
|
|
11
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
12
|
+
Classifier: Operating System :: POSIX
|
|
13
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
14
|
+
Classifier: Programming Language :: Python
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.15
|
|
23
|
+
Classifier: Programming Language :: Python :: Free Threading
|
|
24
|
+
Classifier: Programming Language :: Python :: Free Threading :: 3 - Stable
|
|
25
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
26
|
+
Classifier: Intended Audience :: Developers
|
|
27
|
+
Classifier: Topic :: Software Development :: Libraries
|
|
28
|
+
Classifier: Typing :: Typed
|
|
29
|
+
Requires-Python: >=3.8
|
|
30
|
+
Description-Content-Type: text/markdown
|
|
31
|
+
License-File: LICENSE
|
|
32
|
+
|
|
33
|
+
<details>
|
|
34
|
+
<summary>ⓘ</summary>
|
|
35
|
+
|
|
36
|
+
[](https://pepy.tech/project/throngtest)
|
|
37
|
+
[](https://pepy.tech/project/throngtest)
|
|
38
|
+
[](https://coveralls.io/github/mutating/throngtest?branch=main)
|
|
39
|
+
[](https://github.com/boyter/scc/)
|
|
40
|
+
[](https://hitsofcode.com/github/mutating/throngtest/view?branch=main)
|
|
41
|
+
[](https://github.com/mutating/throngtest/actions/workflows/tests_and_coverage.yml)
|
|
42
|
+
[](https://pypi.python.org/pypi/throngtest)
|
|
43
|
+
[](https://badge.fury.io/py/throngtest)
|
|
44
|
+
[](http://mypy-lang.org/)
|
|
45
|
+
[](https://github.com/astral-sh/ruff)
|
|
46
|
+
[](https://deepwiki.com/mutating/throngtest)
|
|
47
|
+
|
|
48
|
+
</details>
|
|
49
|
+
|
|
50
|
+

|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
Run pytest test subsets in [throng](https://github.com/mutating/throng) isolates.
|
|
54
|
+
Throngtest is an independent pytest plugin: it has its own options and does not
|
|
55
|
+
depend on pytest-xdist or implement xdist's flags or fixtures.
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
pip install throngtest
|
|
59
|
+
pytest
|
|
60
|
+
pytest --throngtest-distribution=files
|
|
61
|
+
pytest --isolates=2 --throngtest-backend=local
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Installing the plugin enables distribution into up to four isolates by default.
|
|
65
|
+
Use `--isolates=0` to disable it and run ordinary pytest.
|
|
66
|
+
Python 3.8+ and pytest 8.3.5–9.x are supported.
|
|
67
|
+
|
|
68
|
+
## Configuration
|
|
69
|
+
|
|
70
|
+
All throngtest settings are loaded, converted and validated through
|
|
71
|
+
[skelet](https://github.com/mutating/skelet). Sources have this precedence:
|
|
72
|
+
|
|
73
|
+
1. Explicit `--throngtest-*` arguments, including arguments supplied by pytest's
|
|
74
|
+
`addopts` or `PYTEST_ADDOPTS`.
|
|
75
|
+
2. Environment variables with the `THRONGTEST_` prefix.
|
|
76
|
+
3. `[tool.throngtest]` in `pyproject.toml` at pytest's `rootdir`.
|
|
77
|
+
4. Defaults.
|
|
78
|
+
|
|
79
|
+
```toml
|
|
80
|
+
[tool.throngtest]
|
|
81
|
+
workers = 4
|
|
82
|
+
check_fingerprints = false
|
|
83
|
+
backend = "temporary_directory"
|
|
84
|
+
distribution = "files"
|
|
85
|
+
preparation = ["python scripts/prepare.py", "python scripts/seed_test_data.py"]
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
```bash
|
|
89
|
+
THRONGTEST_WORKERS=4 pytest
|
|
90
|
+
pytest --isolates=2 --throngtest-exclude='[".git/", ".venv/", "large-data/"]'
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
| Setting | CLI option | Default | Meaning |
|
|
94
|
+
| --- | --- | --- | --- |
|
|
95
|
+
| `workers` | `--isolates` | `4` | Maximum number of nonempty test subsets; a nonnegative integer. `0` disables distribution. |
|
|
96
|
+
| `check_fingerprints` | `--throngtest-check-fingerprints` | `false` | Require identical ordered collections in the controller and isolates. |
|
|
97
|
+
| `backend` | `--throngtest-backend` | `temporary_directory` | Name of an installed throng plugin. |
|
|
98
|
+
| `distribution` | `--throngtest-distribution` | `tests` | Split individual tests or keep each file together (`files`). |
|
|
99
|
+
| `python` | `--throngtest-python` | Controller's `sys.executable` | Python executable available inside each isolate. |
|
|
100
|
+
| `exclude` | `--throngtest-exclude` | See below | Throng snapshot exclusion patterns; a JSON array for CLI/environment sources and an array in TOML. |
|
|
101
|
+
| `preparation` | `--throngtest-preparation` | `[]` | Ordered list of nonempty commands run once in each isolate before pytest; JSON for CLI/environment sources and an array in TOML. |
|
|
102
|
+
|
|
103
|
+
The default exclusions are `.git/`, `.venv/`, `venv/`, `__pycache__/`,
|
|
104
|
+
`.pytest_cache/`, `.mypy_cache/`, `.ruff_cache/`, `build/`, `dist/`, and `mutants/`.
|
|
105
|
+
An explicit exclusion list replaces the defaults. Patterns are interpreted by
|
|
106
|
+
throng. Configurations are read afresh for each pytest session.
|
|
107
|
+
|
|
108
|
+
Fingerprint checks are disabled by default. Enable them with
|
|
109
|
+
`--throngtest-check-fingerprints`, `THRONGTEST_CHECK_FINGERPRINTS=true`, or
|
|
110
|
+
`check_fingerprints = true` in `[tool.throngtest]`. Use
|
|
111
|
+
`--throngtest-no-check-fingerprints` to override an enabled setting from the
|
|
112
|
+
environment or TOML. Both CLI flags take no value; if both are supplied, the
|
|
113
|
+
last flag wins. The environment accepts `true`/`false`; TOML uses booleans.
|
|
114
|
+
|
|
115
|
+
## Isolate preparation
|
|
116
|
+
|
|
117
|
+
Use `preparation` to generate files, install dependencies, or otherwise prepare
|
|
118
|
+
each isolate before its pytest process starts:
|
|
119
|
+
|
|
120
|
+
```bash
|
|
121
|
+
pytest --throngtest-preparation='["python scripts/prepare.py"]'
|
|
122
|
+
THRONGTEST_PREPARATION='["python scripts/prepare.py"]' pytest
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
Commands run in the listed order through `isolate.run`, in the same isolate as
|
|
126
|
+
the tests. With the built-in backends they start at the project root, even when
|
|
127
|
+
pytest is invoked from a subdirectory. Each call starts a separate process:
|
|
128
|
+
file changes persist, but `cd`, `export`, and shell activation do not carry over
|
|
129
|
+
to later commands or pytest. To select a prepared interpreter, set `python` to
|
|
130
|
+
its executable path. Command syntax follows the chosen throng backend.
|
|
131
|
+
|
|
132
|
+
A nonzero command exit code stops preparation of that isolate and prevents its
|
|
133
|
+
tests from starting. The controller cancels outstanding work, cleans up the
|
|
134
|
+
isolates, and exits with code 3, reporting the failed command, its exit code,
|
|
135
|
+
and preparation output. Other isolates may already have started their tests.
|
|
136
|
+
Successful preparation output is forwarded with the isolate's test results.
|
|
137
|
+
|
|
138
|
+
An explicit list replaces the lower-priority list; `[]` disables preparation.
|
|
139
|
+
No preparation runs with `workers = 0`, `--collect-only`, or an empty test
|
|
140
|
+
selection. The controller collects tests before creating isolates, so its
|
|
141
|
+
environment must already support that initial collection. Preparation runs
|
|
142
|
+
before collection inside each worker, not before controller collection.
|
|
143
|
+
|
|
144
|
+
## Coverage
|
|
145
|
+
|
|
146
|
+
Throngtest includes two coverage agents, for `coverage run -m pytest` and
|
|
147
|
+
`pytest --cov`. They are pristan plugins in the `throngtest.coverage` slot.
|
|
148
|
+
Only agents whose coverage tool is active participate in a run. Coverage tools
|
|
149
|
+
are optional dependencies; install the one you intend to use in the controller
|
|
150
|
+
and in every isolate.
|
|
151
|
+
|
|
152
|
+
```bash
|
|
153
|
+
coverage run -m pytest --isolates=4
|
|
154
|
+
coverage combine
|
|
155
|
+
coverage report -m
|
|
156
|
+
|
|
157
|
+
pytest --isolates=4 --cov=your_package
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
Each isolate saves its coverage database under a unique name. After its pytest
|
|
161
|
+
process exits, throngtest runs another command in the same isolate, serializes
|
|
162
|
+
the database into command output, and reconstructs it on the controller. Source
|
|
163
|
+
paths inside copied projects are mapped back to the controller's project path.
|
|
164
|
+
The transport requires no shared filesystem, including with throng backends
|
|
165
|
+
that run on remote machines. With `pytest-cov`, the final report includes the
|
|
166
|
+
transferred data automatically. With `coverage run`, combine the data before
|
|
167
|
+
reporting, as shown above. A `COVERAGE_FILE` path shared with isolates is not
|
|
168
|
+
required.
|
|
169
|
+
|
|
170
|
+
Third-party agents can register a function returning a `CoverageAgent` subclass
|
|
171
|
+
with `@coverage_agents.plugin(unique=True)` and expose that registration module
|
|
172
|
+
through a `throngtest.coverage` entry point. Every active registered agent is
|
|
173
|
+
started in each isolate and has its coverage data returned to the controller.
|
|
174
|
+
An agent implements `active(config)`, `start_worker(marker, configuration,
|
|
175
|
+
root)`, and `stop_worker()`. It can override `configuration(root)` to send
|
|
176
|
+
JSON-safe settings, `pytest_arguments()` to adjust worker options, and
|
|
177
|
+
`data_file()` to name its coverage database. `root` is the project root on
|
|
178
|
+
the corresponding machine.
|
|
179
|
+
|
|
180
|
+
Subprocesses created *inside* a test still need subprocess coverage support
|
|
181
|
+
from the chosen coverage tool. On remote machines, its Python environment also
|
|
182
|
+
needs the agent package installed.
|
|
183
|
+
|
|
184
|
+
## Distribution and execution
|
|
185
|
+
|
|
186
|
+
The controller collects and selects tests using pytest. It partitions the
|
|
187
|
+
result into at most `workers` nonempty subsets. In `tests` mode, tests are
|
|
188
|
+
assigned in round-robin order. In `files` mode, larger files are assigned first
|
|
189
|
+
to the least populated subset, using test counts as the size estimate. Original
|
|
190
|
+
collection order is preserved within each subset. Durations are not predicted
|
|
191
|
+
and work is not reassigned between subsets.
|
|
192
|
+
|
|
193
|
+
Each subset gets one isolate from a single throng manager. A service thread
|
|
194
|
+
waits for its synchronous command; test functions themselves execute in pytest
|
|
195
|
+
inside the isolate. Every worker independently collects and partitions tests.
|
|
196
|
+
The number of partitions is limited to the number of isolates actually started.
|
|
197
|
+
With `check_fingerprints = false` (the default), the collections are not compared
|
|
198
|
+
with the controller, and reports retain the identifiers collected inside each
|
|
199
|
+
isolate. Report completeness is still validated against that isolate's assigned
|
|
200
|
+
subset, including fail-fast handling. Empty subsets are allowed; if no isolate
|
|
201
|
+
executes any tests, the overall run returns pytest's exit code 5.
|
|
202
|
+
|
|
203
|
+
Without fingerprint checks, differences in collection order or contents between
|
|
204
|
+
isolates can cause tests to be omitted or executed more than once. Enable
|
|
205
|
+
`check_fingerprints` when you need to reject these differences before execution.
|
|
206
|
+
With checks enabled, each worker compares its ordered collection fingerprint
|
|
207
|
+
before running tests. A collection mismatch first lists possible causes to check:
|
|
208
|
+
file changes or exclusions, preparation, environment-dependent parametrization,
|
|
209
|
+
unstable ordering, different selection settings or plugins, and absolute paths
|
|
210
|
+
in parameter IDs that change when the project is copied. These are diagnostic
|
|
211
|
+
suggestions, not an automatic determination of the cause. It then reports both
|
|
212
|
+
selected-test counts and a unified diff of the ordered test identifiers (`-` for the controller, `+` for
|
|
213
|
+
the isolate). The diff includes parameter IDs, preserves duplicates, and is
|
|
214
|
+
limited to 100 lines with an explicit truncation notice for larger differences.
|
|
215
|
+
|
|
216
|
+
The built-in backends have different guarantees:
|
|
217
|
+
|
|
218
|
+
* `temporary_directory` copies the project into a separate temporary directory
|
|
219
|
+
for each isolate and removes it after execution. Commands in different
|
|
220
|
+
isolates can run concurrently.
|
|
221
|
+
* `local` executes in the original project directory. Its isolates use separate
|
|
222
|
+
command processes, but throng 0.0.3 serializes commands belonging to one local
|
|
223
|
+
manager. Project file changes are visible to other subsets and remain after
|
|
224
|
+
the run.
|
|
225
|
+
|
|
226
|
+
Throng determines isolation and available concurrency. Throngtest does not
|
|
227
|
+
bypass a manager's synchronization. Without nested xdist, a session fixture runs once **per isolate**;
|
|
228
|
+
module and class fixtures may also be instantiated in multiple isolates in
|
|
229
|
+
`tests` mode. Use `files` to keep a file's fixtures and tests together.
|
|
230
|
+
|
|
231
|
+
## Optional cooperation with pytest-xdist
|
|
232
|
+
|
|
233
|
+
Throngtest does not depend on, install, or enable pytest-xdist. Users who want
|
|
234
|
+
both levels of distribution install and configure xdist separately:
|
|
235
|
+
|
|
236
|
+
```bash
|
|
237
|
+
python -m pip install pytest-xdist
|
|
238
|
+
pytest --isolates=2 -n 4 --dist=load
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
Throngtest partitions the tests between up to two isolates. Each isolate runs
|
|
242
|
+
its preparation once, then starts its own xdist controller with four local
|
|
243
|
+
workers. Xdist distributes only that isolate's subset. The example can execute
|
|
244
|
+
up to eight tests concurrently with `temporary_directory`; the `local` backend
|
|
245
|
+
still serializes isolate commands. Processes belonging to the same isolate
|
|
246
|
+
share its prepared filesystem. A session fixture runs once per xdist worker.
|
|
247
|
+
|
|
248
|
+
`-n`, `--numprocesses`, `--dist`, and other xdist options belong to xdist and
|
|
249
|
+
retain its parsing and configuration through CLI, pytest `addopts`, and
|
|
250
|
+
`PYTEST_ADDOPTS`. Throngtest adds no xdist settings or aliases. Without an
|
|
251
|
+
enabled xdist run, execution stays sequential within each isolate. `-n 0`
|
|
252
|
+
disables inner distribution; `--isolates=0` leaves standalone xdist in control.
|
|
253
|
+
`-n auto` is resolved independently in each isolate and is not a global process
|
|
254
|
+
budget. Xdist's `worker_id` values, such as `gw0`, are local to each isolate.
|
|
255
|
+
|
|
256
|
+
The supported schedulers are `load`, `loadfile`, `loadscope`, `loadgroup`, and
|
|
257
|
+
`worksteal`. Their grouping guarantees apply within each assigned subset.
|
|
258
|
+
For example, use `--throngtest-distribution=files --dist=loadfile` to keep a
|
|
259
|
+
file together at both levels. Xdist groups do not combine tests from different
|
|
260
|
+
isolates. `--dist=each` is rejected because it intentionally repeats tests.
|
|
261
|
+
Explicit `--tx`/`--px` execution environments and `--looponfail` are unsupported;
|
|
262
|
+
inner workers must be local to the isolate and configured with `-n`.
|
|
263
|
+
|
|
264
|
+
Xdist still checks collection consistency between its own workers even when
|
|
265
|
+
throngtest's `check_fingerprints` is disabled. Throngtest accepts interleaved
|
|
266
|
+
results and validates completed executions, including duplicate node IDs,
|
|
267
|
+
fail-fast stops, and xdist worker crashes. Xdist's worker restart settings are
|
|
268
|
+
respected, and crash reports reach the combined terminal and JUnit output.
|
|
269
|
+
Xdist's usual limitations also apply, including its lack of live stdout
|
|
270
|
+
forwarding with `-s`. Captured output on failures is retained.
|
|
271
|
+
|
|
272
|
+
## Results and failures
|
|
273
|
+
|
|
274
|
+
Workers return JSON reports through the command's stdout. No shared report
|
|
275
|
+
directory, network listener, or pickle transport is required. Third-party
|
|
276
|
+
throng backends must provide stdout and a process return code. The selected
|
|
277
|
+
interpreter must have throngtest, pytest, the project's dependencies, and
|
|
278
|
+
required pytest plugins available by the end of preparation. Throngtest only
|
|
279
|
+
installs packages when explicitly instructed through preparation commands.
|
|
280
|
+
For a remote backend, set `--throngtest-python` to an interpreter available in
|
|
281
|
+
the isolate, such as `python`; its default is the controller's absolute
|
|
282
|
+
`sys.executable` path, which is usually absent on a remote machine.
|
|
283
|
+
|
|
284
|
+
The controller replays pytest reports, preserving assertion explanations,
|
|
285
|
+
captured output, skip/xfail/xpass results, setup/teardown failures, durations,
|
|
286
|
+
and test properties. `--junitxml` produces one aggregate report. Runtime warnings
|
|
287
|
+
are forwarded with their original category name in the message. `-s` output is
|
|
288
|
+
forwarded after its subset completes. Reports are buffered per subset; there is
|
|
289
|
+
no live per-test progress from a running isolate.
|
|
290
|
+
|
|
291
|
+
`-k`, `-m`, explicit node IDs, parametrization, conftest fixtures, `--collect-only`,
|
|
292
|
+
and `--continue-on-collection-errors` are supported. Empty collections retain
|
|
293
|
+
pytest's exit code 5. Isolate process crashes, missing interpreters, collection mismatches
|
|
294
|
+
with fingerprint checks enabled, and incomplete report payloads fail with exit code 3. A reported
|
|
295
|
+
worker interrupt propagates exit code 2.
|
|
296
|
+
|
|
297
|
+
`-x` and `--maxfail` apply within each worker and to the aggregate reports. Once
|
|
298
|
+
the controller observes the limit, it cancels outstanding commands through
|
|
299
|
+
throng's cancellation token and cleans up isolates. Other subsets may already
|
|
300
|
+
have executed additional tests. Cancellation responsiveness depends on the
|
|
301
|
+
backend; throng's isolate creation itself does not accept a cancellation token.
|
|
302
|
+
|
|
303
|
+
The plugin rejects interactive `--pdb`, cache-based selection (`--lf`, `--ff`, `--nf`), and
|
|
304
|
+
`--stepwise`. Other plugins must be importable in each worker, for example via
|
|
305
|
+
installation, `-p`, or conftest; programmatically injected plugin objects cannot
|
|
306
|
+
be transported. Plugins that implement custom test protocols, reruns, or their
|
|
307
|
+
own output artifacts need separate compatibility work. The built-in throng
|
|
308
|
+
backends reuse the interpreter environment; temporary file copies are not
|
|
309
|
+
container or virtual-environment isolation.
|
|
310
|
+
|
|
311
|
+
## Development
|
|
312
|
+
|
|
313
|
+
```bash
|
|
314
|
+
python -m pip install -r requirements_dev.txt -e .
|
|
315
|
+
python -m pytest --isolates=0
|
|
316
|
+
ruff check throngtest tests
|
|
317
|
+
mypy --strict --disallow-any-decorated --disallow-any-explicit \
|
|
318
|
+
--disallow-any-expr --disallow-any-generics --disallow-any-unimported \
|
|
319
|
+
--disallow-subclassing-any --warn-return-any throngtest
|
|
320
|
+
mypy tests
|
|
321
|
+
```
|
|
322
|
+
|
|
323
|
+
The outer test session disables distribution; integration tests launch their
|
|
324
|
+
own pytest sessions to exercise throngtest, including its default settings.
|
|
325
|
+
The test suite includes actual subprocess runs through both built-in throng
|
|
326
|
+
plugins, trace checks of their isolate APIs, complete/disjoint distribution,
|
|
327
|
+
concurrency barriers, configuration precedence, preparation, native reports, cancellation,
|
|
328
|
+
cleanup, and fault injection at the protocol/backend boundaries. The existing
|
|
329
|
+
CI also checks statement and branch coverage across Python and OS versions.
|
|
330
|
+
The CI workflow uses a startup hook to measure its own local subprocesses.
|
|
331
|
+
Integration tests also verify that the coverage agents transfer data from
|
|
332
|
+
temporary isolates, including when pytest-xdist runs inside them.
|