pytest-sort 0.0.2__tar.gz → 0.0.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.
- pytest-sort-0.0.3/PKG-INFO +191 -0
- pytest-sort-0.0.3/README.md +152 -0
- {pytest-sort-0.0.2 → pytest-sort-0.0.3}/pyproject.toml +6 -4
- {pytest-sort-0.0.2 → pytest-sort-0.0.3}/src/pytest_sort/config.py +12 -6
- {pytest-sort-0.0.2 → pytest-sort-0.0.3}/src/pytest_sort/plugin.py +10 -9
- pytest-sort-0.0.3/src/pytest_sort.egg-info/PKG-INFO +191 -0
- pytest-sort-0.0.2/PKG-INFO +0 -110
- pytest-sort-0.0.2/README.md +0 -71
- pytest-sort-0.0.2/src/pytest_sort.egg-info/PKG-INFO +0 -110
- {pytest-sort-0.0.2 → pytest-sort-0.0.3}/LICENSE +0 -0
- {pytest-sort-0.0.2 → pytest-sort-0.0.3}/setup.cfg +0 -0
- {pytest-sort-0.0.2 → pytest-sort-0.0.3}/src/pytest_sort/__init__.py +0 -0
- {pytest-sort-0.0.2 → pytest-sort-0.0.3}/src/pytest_sort/database.py +0 -0
- {pytest-sort-0.0.2 → pytest-sort-0.0.3}/src/pytest_sort.egg-info/SOURCES.txt +0 -0
- {pytest-sort-0.0.2 → pytest-sort-0.0.3}/src/pytest_sort.egg-info/dependency_links.txt +0 -0
- {pytest-sort-0.0.2 → pytest-sort-0.0.3}/src/pytest_sort.egg-info/entry_points.txt +0 -0
- {pytest-sort-0.0.2 → pytest-sort-0.0.3}/src/pytest_sort.egg-info/requires.txt +0 -0
- {pytest-sort-0.0.2 → pytest-sort-0.0.3}/src/pytest_sort.egg-info/top_level.txt +0 -0
- {pytest-sort-0.0.2 → pytest-sort-0.0.3}/test/test_database.py +0 -0
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: pytest-sort
|
|
3
|
+
Version: 0.0.3
|
|
4
|
+
Summary: Tools for sorting test cases
|
|
5
|
+
Author-email: Peter Busch <pbuschmail-pytestsort@yahoo.com>
|
|
6
|
+
Maintainer-email: Peter Busch <pbuschmail-pytestsort@yahoo.com>
|
|
7
|
+
License: MIT License
|
|
8
|
+
|
|
9
|
+
Copyright (c) 2023 Peter Busch
|
|
10
|
+
|
|
11
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
12
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
13
|
+
in the Software without restriction, including without limitation the rights
|
|
14
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
15
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
16
|
+
furnished to do so, subject to the following conditions:
|
|
17
|
+
|
|
18
|
+
The above copyright notice and this permission notice shall be included in all
|
|
19
|
+
copies or substantial portions of the Software.
|
|
20
|
+
|
|
21
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
22
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
23
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
24
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
25
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
26
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
27
|
+
SOFTWARE.
|
|
28
|
+
|
|
29
|
+
Project-URL: Homepage, https://github.com/WiredNerd/pytest-sort
|
|
30
|
+
Project-URL: Bug Tracker, https://github.com/WiredNerd/pytest-sort/issues
|
|
31
|
+
Keywords: test,pytest,order,sort,random,randomly
|
|
32
|
+
Classifier: Programming Language :: Python :: 3
|
|
33
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
34
|
+
Classifier: Operating System :: OS Independent
|
|
35
|
+
Classifier: Framework :: Pytest
|
|
36
|
+
Requires-Python: >=3.8
|
|
37
|
+
Description-Content-Type: text/markdown
|
|
38
|
+
License-File: LICENSE
|
|
39
|
+
|
|
40
|
+

|
|
41
|
+
|
|
42
|
+
# Project description
|
|
43
|
+
|
|
44
|
+
pytest-sort is a pytest plugin to automatically change the execution order of test cases. Changing the order of execution can help find test cases that only succeed because of a favorable state.
|
|
45
|
+
|
|
46
|
+
This plugin provides several options for controlling how the test cases are reordered.
|
|
47
|
+
|
|
48
|
+
# Quick Start
|
|
49
|
+
|
|
50
|
+
Installation:
|
|
51
|
+
|
|
52
|
+
```
|
|
53
|
+
pip install pytest-sort --upgrade
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Running with pytest-sort:
|
|
57
|
+
|
|
58
|
+
```
|
|
59
|
+
pytest --sort_mode=random
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
By default, all tests from the same module will run together. This command will run the tests within the module in a random order.
|
|
63
|
+
|
|
64
|
+
```
|
|
65
|
+
pytest --help
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
In the pytest-sort section, all currently avaialable options will be listed.
|
|
69
|
+
|
|
70
|
+
You may also set options in any [pytest configruation file](https://docs.pytest.org/en/stable/reference/customize.html).
|
|
71
|
+
|
|
72
|
+
# Usage
|
|
73
|
+
|
|
74
|
+
Ideally, all test cases should be small and independant. This package provides several options for validating if test cases can really be run independantly, or if running them in a specific order is required.
|
|
75
|
+
|
|
76
|
+
## Deterministic but Unpredictable
|
|
77
|
+
|
|
78
|
+
The Junit package automatically runs test cases in a deterministic, but unpredictable order. This package can provide similar functionality in pytest several ways.
|
|
79
|
+
|
|
80
|
+
1. Using sort mode "md5" will produce the same order of tests every time as long as the test case names don't change.
|
|
81
|
+
```toml
|
|
82
|
+
sort_mode="md5"
|
|
83
|
+
```
|
|
84
|
+
2. Using sort mode "random" with a fixed sort seed value will produce the same order of tests every time unles the list of test cases is changed (new test case, or name changes)
|
|
85
|
+
```toml
|
|
86
|
+
sort_mode="random"
|
|
87
|
+
sort_seed=100
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## Random
|
|
91
|
+
|
|
92
|
+
By running in random mode, the test case order will change every time. If a test case fails unexpectedly, you can use the seed from the failed run to determine what order is causing the tests to fail.
|
|
93
|
+
|
|
94
|
+
```toml
|
|
95
|
+
sort_mode="random"
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
## Fail Fast
|
|
99
|
+
|
|
100
|
+
When you have a test suite that includes long running test cases, it can be helpful to delay the longer running test cases till later. The 'fastest' mode allows you to track how long different test cases take to run. Then always run the fastest test cases first, and the slow test cases last.
|
|
101
|
+
```cmd
|
|
102
|
+
pytest --exitfirst --sort-mode=fastest
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
# Options
|
|
107
|
+
|
|
108
|
+
## Sort Mode
|
|
109
|
+
|
|
110
|
+
This option controlls how the order is modified within each bucket.
|
|
111
|
+
|
|
112
|
+
This option must be set to something other than "none" to enable pytest_sort plugin.
|
|
113
|
+
|
|
114
|
+
***Command Line:*** `--sort-mode`
|
|
115
|
+
|
|
116
|
+
***Pytest Config:*** `sort_mode`
|
|
117
|
+
|
|
118
|
+
***Default:*** `none`
|
|
119
|
+
|
|
120
|
+
| Option | Definition |
|
|
121
|
+
| --- | --- |
|
|
122
|
+
| none | pytest_sort will not modify the sort order. This option disables pytest_sort. |
|
|
123
|
+
| md5 | This mode creates an md5 of each test case id, then sorts on those values. <br> This runs test cases in a deterministicly shuffled order. |
|
|
124
|
+
| random | Test cases are shuffled randomly |
|
|
125
|
+
| fastest | In each run in "fasttest" mode, the plugin will track the longest execution time for each test case in a file ".pytest-sort". <br> At the beginning of a test run, any previously recorded values will be used to sort the tests so that the fastest test runs first.
|
|
126
|
+
|
|
127
|
+
## Sort Bucket
|
|
128
|
+
|
|
129
|
+
Sort test order within specified test buckets.
|
|
130
|
+
|
|
131
|
+
For example, if the sort bucket is "module", then all tests from the same module will be completed before running tests for the next module.
|
|
132
|
+
|
|
133
|
+
***Command Line:*** `--sort-bucket`
|
|
134
|
+
|
|
135
|
+
***Pytest Config:*** `sort_bucket`
|
|
136
|
+
|
|
137
|
+
***Default:*** `module`
|
|
138
|
+
|
|
139
|
+
| Option | Definition |
|
|
140
|
+
| --- | --- |
|
|
141
|
+
| global | Apply sort to all items together. |
|
|
142
|
+
| package | Group together test cases that are in the same package (folder). |
|
|
143
|
+
| module | Group together test cases that are in the same module (py file). |
|
|
144
|
+
| class | Group together test cases that are members of a class. <br>All other (non-class) test cases are grouped by module. |
|
|
145
|
+
| parent | Group together test cases by their immediate parent. |
|
|
146
|
+
| grandparent | Group together test cases by their parent's parent. |
|
|
147
|
+
|
|
148
|
+
## Sort Seed
|
|
149
|
+
|
|
150
|
+
Only used in "random" sort mode. This field allows you to manually set the seed used by random package when sorting tests.
|
|
151
|
+
|
|
152
|
+
> Tip: Seed is printed in the pytest header
|
|
153
|
+
|
|
154
|
+
***Command Line:*** `--sort-seed`
|
|
155
|
+
|
|
156
|
+
***Pytest Config:*** `sort_seed`
|
|
157
|
+
|
|
158
|
+
***Default:*** A random integer between 0 and 1,000,000 generated at runtime.
|
|
159
|
+
|
|
160
|
+
## Record Test Runtimes
|
|
161
|
+
|
|
162
|
+
This option enables or disables pytest_sort to record test case runtimes. These runtimes are used when sort mode is "fastest". When sort mode is "fastest" recording is enabled by default, otherwise this is disabled by default.
|
|
163
|
+
|
|
164
|
+
***Command Line:*** `--sort-record-times/--sort-no-record-times`
|
|
165
|
+
|
|
166
|
+
***Pytest Config:*** `sort_record_times`
|
|
167
|
+
|
|
168
|
+
***Default:*** false
|
|
169
|
+
|
|
170
|
+
| Option | Definition |
|
|
171
|
+
| --- | --- |
|
|
172
|
+
| `--sort-record-times`<br>`sort_record_times=true` | Record test case runtime statistics |
|
|
173
|
+
| `--sort-no-record-times`<br>`sort_record_times=false` | Disable recording runtime statistics in "fastest" mode |
|
|
174
|
+
|
|
175
|
+
## Reset Recorded Test Runtimes
|
|
176
|
+
|
|
177
|
+
Clear all recorded runtimes before sorting the next test.
|
|
178
|
+
|
|
179
|
+
When recording runtimes, only the highest runtime values for each test case are retained. After significant changes to test cases that can change how fast they run, it is advisable to reset the runtimes. This can help maintain more accurate sorting in "fastest" mode.
|
|
180
|
+
|
|
181
|
+
***Command Line:*** `--sort-reset-times`
|
|
182
|
+
|
|
183
|
+
***Pytest Config:*** N/A
|
|
184
|
+
|
|
185
|
+
## Report Recorded Test Runtimes
|
|
186
|
+
|
|
187
|
+
At the end of the test run, print out the currently saved test runtimes.
|
|
188
|
+
|
|
189
|
+
***Command Line:*** `--sort-reset-times`
|
|
190
|
+
|
|
191
|
+
***Pytest Config:*** N/A
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+

|
|
2
|
+
|
|
3
|
+
# Project description
|
|
4
|
+
|
|
5
|
+
pytest-sort is a pytest plugin to automatically change the execution order of test cases. Changing the order of execution can help find test cases that only succeed because of a favorable state.
|
|
6
|
+
|
|
7
|
+
This plugin provides several options for controlling how the test cases are reordered.
|
|
8
|
+
|
|
9
|
+
# Quick Start
|
|
10
|
+
|
|
11
|
+
Installation:
|
|
12
|
+
|
|
13
|
+
```
|
|
14
|
+
pip install pytest-sort --upgrade
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Running with pytest-sort:
|
|
18
|
+
|
|
19
|
+
```
|
|
20
|
+
pytest --sort_mode=random
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
By default, all tests from the same module will run together. This command will run the tests within the module in a random order.
|
|
24
|
+
|
|
25
|
+
```
|
|
26
|
+
pytest --help
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
In the pytest-sort section, all currently avaialable options will be listed.
|
|
30
|
+
|
|
31
|
+
You may also set options in any [pytest configruation file](https://docs.pytest.org/en/stable/reference/customize.html).
|
|
32
|
+
|
|
33
|
+
# Usage
|
|
34
|
+
|
|
35
|
+
Ideally, all test cases should be small and independant. This package provides several options for validating if test cases can really be run independantly, or if running them in a specific order is required.
|
|
36
|
+
|
|
37
|
+
## Deterministic but Unpredictable
|
|
38
|
+
|
|
39
|
+
The Junit package automatically runs test cases in a deterministic, but unpredictable order. This package can provide similar functionality in pytest several ways.
|
|
40
|
+
|
|
41
|
+
1. Using sort mode "md5" will produce the same order of tests every time as long as the test case names don't change.
|
|
42
|
+
```toml
|
|
43
|
+
sort_mode="md5"
|
|
44
|
+
```
|
|
45
|
+
2. Using sort mode "random" with a fixed sort seed value will produce the same order of tests every time unles the list of test cases is changed (new test case, or name changes)
|
|
46
|
+
```toml
|
|
47
|
+
sort_mode="random"
|
|
48
|
+
sort_seed=100
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Random
|
|
52
|
+
|
|
53
|
+
By running in random mode, the test case order will change every time. If a test case fails unexpectedly, you can use the seed from the failed run to determine what order is causing the tests to fail.
|
|
54
|
+
|
|
55
|
+
```toml
|
|
56
|
+
sort_mode="random"
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Fail Fast
|
|
60
|
+
|
|
61
|
+
When you have a test suite that includes long running test cases, it can be helpful to delay the longer running test cases till later. The 'fastest' mode allows you to track how long different test cases take to run. Then always run the fastest test cases first, and the slow test cases last.
|
|
62
|
+
```cmd
|
|
63
|
+
pytest --exitfirst --sort-mode=fastest
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
# Options
|
|
68
|
+
|
|
69
|
+
## Sort Mode
|
|
70
|
+
|
|
71
|
+
This option controlls how the order is modified within each bucket.
|
|
72
|
+
|
|
73
|
+
This option must be set to something other than "none" to enable pytest_sort plugin.
|
|
74
|
+
|
|
75
|
+
***Command Line:*** `--sort-mode`
|
|
76
|
+
|
|
77
|
+
***Pytest Config:*** `sort_mode`
|
|
78
|
+
|
|
79
|
+
***Default:*** `none`
|
|
80
|
+
|
|
81
|
+
| Option | Definition |
|
|
82
|
+
| --- | --- |
|
|
83
|
+
| none | pytest_sort will not modify the sort order. This option disables pytest_sort. |
|
|
84
|
+
| md5 | This mode creates an md5 of each test case id, then sorts on those values. <br> This runs test cases in a deterministicly shuffled order. |
|
|
85
|
+
| random | Test cases are shuffled randomly |
|
|
86
|
+
| fastest | In each run in "fasttest" mode, the plugin will track the longest execution time for each test case in a file ".pytest-sort". <br> At the beginning of a test run, any previously recorded values will be used to sort the tests so that the fastest test runs first.
|
|
87
|
+
|
|
88
|
+
## Sort Bucket
|
|
89
|
+
|
|
90
|
+
Sort test order within specified test buckets.
|
|
91
|
+
|
|
92
|
+
For example, if the sort bucket is "module", then all tests from the same module will be completed before running tests for the next module.
|
|
93
|
+
|
|
94
|
+
***Command Line:*** `--sort-bucket`
|
|
95
|
+
|
|
96
|
+
***Pytest Config:*** `sort_bucket`
|
|
97
|
+
|
|
98
|
+
***Default:*** `module`
|
|
99
|
+
|
|
100
|
+
| Option | Definition |
|
|
101
|
+
| --- | --- |
|
|
102
|
+
| global | Apply sort to all items together. |
|
|
103
|
+
| package | Group together test cases that are in the same package (folder). |
|
|
104
|
+
| module | Group together test cases that are in the same module (py file). |
|
|
105
|
+
| class | Group together test cases that are members of a class. <br>All other (non-class) test cases are grouped by module. |
|
|
106
|
+
| parent | Group together test cases by their immediate parent. |
|
|
107
|
+
| grandparent | Group together test cases by their parent's parent. |
|
|
108
|
+
|
|
109
|
+
## Sort Seed
|
|
110
|
+
|
|
111
|
+
Only used in "random" sort mode. This field allows you to manually set the seed used by random package when sorting tests.
|
|
112
|
+
|
|
113
|
+
> Tip: Seed is printed in the pytest header
|
|
114
|
+
|
|
115
|
+
***Command Line:*** `--sort-seed`
|
|
116
|
+
|
|
117
|
+
***Pytest Config:*** `sort_seed`
|
|
118
|
+
|
|
119
|
+
***Default:*** A random integer between 0 and 1,000,000 generated at runtime.
|
|
120
|
+
|
|
121
|
+
## Record Test Runtimes
|
|
122
|
+
|
|
123
|
+
This option enables or disables pytest_sort to record test case runtimes. These runtimes are used when sort mode is "fastest". When sort mode is "fastest" recording is enabled by default, otherwise this is disabled by default.
|
|
124
|
+
|
|
125
|
+
***Command Line:*** `--sort-record-times/--sort-no-record-times`
|
|
126
|
+
|
|
127
|
+
***Pytest Config:*** `sort_record_times`
|
|
128
|
+
|
|
129
|
+
***Default:*** false
|
|
130
|
+
|
|
131
|
+
| Option | Definition |
|
|
132
|
+
| --- | --- |
|
|
133
|
+
| `--sort-record-times`<br>`sort_record_times=true` | Record test case runtime statistics |
|
|
134
|
+
| `--sort-no-record-times`<br>`sort_record_times=false` | Disable recording runtime statistics in "fastest" mode |
|
|
135
|
+
|
|
136
|
+
## Reset Recorded Test Runtimes
|
|
137
|
+
|
|
138
|
+
Clear all recorded runtimes before sorting the next test.
|
|
139
|
+
|
|
140
|
+
When recording runtimes, only the highest runtime values for each test case are retained. After significant changes to test cases that can change how fast they run, it is advisable to reset the runtimes. This can help maintain more accurate sorting in "fastest" mode.
|
|
141
|
+
|
|
142
|
+
***Command Line:*** `--sort-reset-times`
|
|
143
|
+
|
|
144
|
+
***Pytest Config:*** N/A
|
|
145
|
+
|
|
146
|
+
## Report Recorded Test Runtimes
|
|
147
|
+
|
|
148
|
+
At the end of the test run, print out the currently saved test runtimes.
|
|
149
|
+
|
|
150
|
+
***Command Line:*** `--sort-reset-times`
|
|
151
|
+
|
|
152
|
+
***Pytest Config:*** N/A
|
|
@@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta"
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "pytest-sort"
|
|
7
7
|
description = "Tools for sorting test cases"
|
|
8
|
-
version = "0.0.
|
|
8
|
+
version = "0.0.3"
|
|
9
9
|
license = { file = "LICENSE" }
|
|
10
10
|
keywords = ["test", "pytest", "order", "sort", "random", "randomly"]
|
|
11
11
|
authors = [{ name = "Peter Busch", email = "pbuschmail-pytestsort@yahoo.com" }]
|
|
@@ -65,9 +65,11 @@ files = "src"
|
|
|
65
65
|
target-version = "py38"
|
|
66
66
|
select = ["ALL"]
|
|
67
67
|
ignore = [
|
|
68
|
-
"D203",
|
|
69
|
-
"D213",
|
|
70
|
-
"
|
|
68
|
+
"D203", # 1 blank line required before class docstring
|
|
69
|
+
"D213", # multi-line-summary-second-line
|
|
70
|
+
"EM101", # Exception must not use a string literal, assign to variable first
|
|
71
|
+
"S311", # Standard pseudo-random generators are not suitable for cryptographic purposes
|
|
72
|
+
"TRY003", # Avoid specifying long messages outside the exception class
|
|
71
73
|
]
|
|
72
74
|
line-length = 120
|
|
73
75
|
exclude = [
|
|
@@ -12,11 +12,11 @@ if TYPE_CHECKING:
|
|
|
12
12
|
class SortConfig:
|
|
13
13
|
"""Statoc class for storing configuration of pytest_sort."""
|
|
14
14
|
|
|
15
|
-
mode = "none"
|
|
16
|
-
bucket = "module"
|
|
17
|
-
record = False
|
|
18
|
-
reset = False
|
|
19
|
-
report = False
|
|
15
|
+
mode: str = "none"
|
|
16
|
+
bucket: str = "module"
|
|
17
|
+
record: bool | None = False
|
|
18
|
+
reset: bool = False
|
|
19
|
+
report: bool = False
|
|
20
20
|
|
|
21
21
|
seed = random.randint(0, 1_000_000)
|
|
22
22
|
|
|
@@ -26,8 +26,14 @@ class SortConfig:
|
|
|
26
26
|
SortConfig.mode = config.getoption("sort_mode") or config.getini("sort_mode") or "none"
|
|
27
27
|
SortConfig.bucket = config.getoption("sort_bucket") or config.getini("sort_bucket") or "module"
|
|
28
28
|
|
|
29
|
+
if config.getoption("sort_no_record") and config.getoption("sort_record"):
|
|
30
|
+
raise ValueError("Do not use both --sort-record-times and --sort-no-record-times")
|
|
31
|
+
|
|
32
|
+
if config.getoption("sort_no_record"):
|
|
33
|
+
SortConfig.record = False
|
|
34
|
+
else:
|
|
35
|
+
SortConfig.record = config.getoption("sort_record") or config.getini("sort_record_times")
|
|
29
36
|
# getini returns [] when option not specified
|
|
30
|
-
SortConfig.record = config.getoption("sort_record") or config.getini("sort_record_times")
|
|
31
37
|
if not isinstance(SortConfig.record, bool):
|
|
32
38
|
SortConfig.record = None
|
|
33
39
|
if SortConfig.mode == "fastest" and SortConfig.record is None:
|
|
@@ -64,11 +64,6 @@ def pytest_addoption(parser: pytest.Parser) -> None:
|
|
|
64
64
|
"""pytest_sort: Add command line and ini options to pytest."""
|
|
65
65
|
group = parser.getgroup("pytest-sort")
|
|
66
66
|
|
|
67
|
-
help_text = "Sort test order within specified test buckets. (default: module)"
|
|
68
|
-
choices = ["global", "package", "module", "class", "parent", "grandparent"]
|
|
69
|
-
group.addoption("--sort-bucket", action="store", dest="sort_bucket", choices=choices, help=help_text)
|
|
70
|
-
parser.addini("sort_bucket", help=str(choices))
|
|
71
|
-
|
|
72
67
|
help_text = """
|
|
73
68
|
none = (default) pytest_sort will not modify order.
|
|
74
69
|
md5 = Sort by md5 of test name.
|
|
@@ -79,8 +74,18 @@ def pytest_addoption(parser: pytest.Parser) -> None:
|
|
|
79
74
|
group.addoption("--sort-mode", action="store", dest="sort_mode", choices=choices, help=help_text)
|
|
80
75
|
parser.addini("sort_mode", help=str(choices))
|
|
81
76
|
|
|
77
|
+
help_text = "Sort test order within specified test buckets. (default: module)"
|
|
78
|
+
choices = ["global", "package", "module", "class", "parent", "grandparent"]
|
|
79
|
+
group.addoption("--sort-bucket", action="store", dest="sort_bucket", choices=choices, help=help_text)
|
|
80
|
+
parser.addini("sort_bucket", help=str(choices))
|
|
81
|
+
|
|
82
|
+
help_text = "Random Seed to use with random mode."
|
|
83
|
+
group.addoption("--sort-seed", action="store", dest="sort_seed", help=help_text)
|
|
84
|
+
parser.addini("sort_seed", help=help_text)
|
|
85
|
+
|
|
82
86
|
help_text = "Records runtimes. Activated by default when sort-mode=fastest"
|
|
83
87
|
group.addoption("--sort-record-times", action="store_true", dest="sort_record", help=help_text)
|
|
88
|
+
group.addoption("--sort-no-record-times", action="store_true", dest="sort_no_record", help=help_text)
|
|
84
89
|
parser.addini("sort_record_times", help=help_text, type="bool")
|
|
85
90
|
|
|
86
91
|
help_text = "Clear the recorded runtimes before sorting."
|
|
@@ -89,10 +94,6 @@ def pytest_addoption(parser: pytest.Parser) -> None:
|
|
|
89
94
|
help_text = "At end of report current times."
|
|
90
95
|
group.addoption("--sort-report-times", action="store_true", dest="sort_report_times", help=help_text)
|
|
91
96
|
|
|
92
|
-
help_text = "Random Seed to use with random mode."
|
|
93
|
-
group.addoption("--sort-seed", action="store", dest="sort_seed", help=help_text)
|
|
94
|
-
parser.addini("sort_seed", help=help_text)
|
|
95
|
-
|
|
96
97
|
|
|
97
98
|
def pytest_configure(config: pytest.Config) -> None:
|
|
98
99
|
"""pytest_sort: Add markers to pytest."""
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: pytest-sort
|
|
3
|
+
Version: 0.0.3
|
|
4
|
+
Summary: Tools for sorting test cases
|
|
5
|
+
Author-email: Peter Busch <pbuschmail-pytestsort@yahoo.com>
|
|
6
|
+
Maintainer-email: Peter Busch <pbuschmail-pytestsort@yahoo.com>
|
|
7
|
+
License: MIT License
|
|
8
|
+
|
|
9
|
+
Copyright (c) 2023 Peter Busch
|
|
10
|
+
|
|
11
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
12
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
13
|
+
in the Software without restriction, including without limitation the rights
|
|
14
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
15
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
16
|
+
furnished to do so, subject to the following conditions:
|
|
17
|
+
|
|
18
|
+
The above copyright notice and this permission notice shall be included in all
|
|
19
|
+
copies or substantial portions of the Software.
|
|
20
|
+
|
|
21
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
22
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
23
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
24
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
25
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
26
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
27
|
+
SOFTWARE.
|
|
28
|
+
|
|
29
|
+
Project-URL: Homepage, https://github.com/WiredNerd/pytest-sort
|
|
30
|
+
Project-URL: Bug Tracker, https://github.com/WiredNerd/pytest-sort/issues
|
|
31
|
+
Keywords: test,pytest,order,sort,random,randomly
|
|
32
|
+
Classifier: Programming Language :: Python :: 3
|
|
33
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
34
|
+
Classifier: Operating System :: OS Independent
|
|
35
|
+
Classifier: Framework :: Pytest
|
|
36
|
+
Requires-Python: >=3.8
|
|
37
|
+
Description-Content-Type: text/markdown
|
|
38
|
+
License-File: LICENSE
|
|
39
|
+
|
|
40
|
+

|
|
41
|
+
|
|
42
|
+
# Project description
|
|
43
|
+
|
|
44
|
+
pytest-sort is a pytest plugin to automatically change the execution order of test cases. Changing the order of execution can help find test cases that only succeed because of a favorable state.
|
|
45
|
+
|
|
46
|
+
This plugin provides several options for controlling how the test cases are reordered.
|
|
47
|
+
|
|
48
|
+
# Quick Start
|
|
49
|
+
|
|
50
|
+
Installation:
|
|
51
|
+
|
|
52
|
+
```
|
|
53
|
+
pip install pytest-sort --upgrade
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Running with pytest-sort:
|
|
57
|
+
|
|
58
|
+
```
|
|
59
|
+
pytest --sort_mode=random
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
By default, all tests from the same module will run together. This command will run the tests within the module in a random order.
|
|
63
|
+
|
|
64
|
+
```
|
|
65
|
+
pytest --help
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
In the pytest-sort section, all currently avaialable options will be listed.
|
|
69
|
+
|
|
70
|
+
You may also set options in any [pytest configruation file](https://docs.pytest.org/en/stable/reference/customize.html).
|
|
71
|
+
|
|
72
|
+
# Usage
|
|
73
|
+
|
|
74
|
+
Ideally, all test cases should be small and independant. This package provides several options for validating if test cases can really be run independantly, or if running them in a specific order is required.
|
|
75
|
+
|
|
76
|
+
## Deterministic but Unpredictable
|
|
77
|
+
|
|
78
|
+
The Junit package automatically runs test cases in a deterministic, but unpredictable order. This package can provide similar functionality in pytest several ways.
|
|
79
|
+
|
|
80
|
+
1. Using sort mode "md5" will produce the same order of tests every time as long as the test case names don't change.
|
|
81
|
+
```toml
|
|
82
|
+
sort_mode="md5"
|
|
83
|
+
```
|
|
84
|
+
2. Using sort mode "random" with a fixed sort seed value will produce the same order of tests every time unles the list of test cases is changed (new test case, or name changes)
|
|
85
|
+
```toml
|
|
86
|
+
sort_mode="random"
|
|
87
|
+
sort_seed=100
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## Random
|
|
91
|
+
|
|
92
|
+
By running in random mode, the test case order will change every time. If a test case fails unexpectedly, you can use the seed from the failed run to determine what order is causing the tests to fail.
|
|
93
|
+
|
|
94
|
+
```toml
|
|
95
|
+
sort_mode="random"
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
## Fail Fast
|
|
99
|
+
|
|
100
|
+
When you have a test suite that includes long running test cases, it can be helpful to delay the longer running test cases till later. The 'fastest' mode allows you to track how long different test cases take to run. Then always run the fastest test cases first, and the slow test cases last.
|
|
101
|
+
```cmd
|
|
102
|
+
pytest --exitfirst --sort-mode=fastest
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
# Options
|
|
107
|
+
|
|
108
|
+
## Sort Mode
|
|
109
|
+
|
|
110
|
+
This option controlls how the order is modified within each bucket.
|
|
111
|
+
|
|
112
|
+
This option must be set to something other than "none" to enable pytest_sort plugin.
|
|
113
|
+
|
|
114
|
+
***Command Line:*** `--sort-mode`
|
|
115
|
+
|
|
116
|
+
***Pytest Config:*** `sort_mode`
|
|
117
|
+
|
|
118
|
+
***Default:*** `none`
|
|
119
|
+
|
|
120
|
+
| Option | Definition |
|
|
121
|
+
| --- | --- |
|
|
122
|
+
| none | pytest_sort will not modify the sort order. This option disables pytest_sort. |
|
|
123
|
+
| md5 | This mode creates an md5 of each test case id, then sorts on those values. <br> This runs test cases in a deterministicly shuffled order. |
|
|
124
|
+
| random | Test cases are shuffled randomly |
|
|
125
|
+
| fastest | In each run in "fasttest" mode, the plugin will track the longest execution time for each test case in a file ".pytest-sort". <br> At the beginning of a test run, any previously recorded values will be used to sort the tests so that the fastest test runs first.
|
|
126
|
+
|
|
127
|
+
## Sort Bucket
|
|
128
|
+
|
|
129
|
+
Sort test order within specified test buckets.
|
|
130
|
+
|
|
131
|
+
For example, if the sort bucket is "module", then all tests from the same module will be completed before running tests for the next module.
|
|
132
|
+
|
|
133
|
+
***Command Line:*** `--sort-bucket`
|
|
134
|
+
|
|
135
|
+
***Pytest Config:*** `sort_bucket`
|
|
136
|
+
|
|
137
|
+
***Default:*** `module`
|
|
138
|
+
|
|
139
|
+
| Option | Definition |
|
|
140
|
+
| --- | --- |
|
|
141
|
+
| global | Apply sort to all items together. |
|
|
142
|
+
| package | Group together test cases that are in the same package (folder). |
|
|
143
|
+
| module | Group together test cases that are in the same module (py file). |
|
|
144
|
+
| class | Group together test cases that are members of a class. <br>All other (non-class) test cases are grouped by module. |
|
|
145
|
+
| parent | Group together test cases by their immediate parent. |
|
|
146
|
+
| grandparent | Group together test cases by their parent's parent. |
|
|
147
|
+
|
|
148
|
+
## Sort Seed
|
|
149
|
+
|
|
150
|
+
Only used in "random" sort mode. This field allows you to manually set the seed used by random package when sorting tests.
|
|
151
|
+
|
|
152
|
+
> Tip: Seed is printed in the pytest header
|
|
153
|
+
|
|
154
|
+
***Command Line:*** `--sort-seed`
|
|
155
|
+
|
|
156
|
+
***Pytest Config:*** `sort_seed`
|
|
157
|
+
|
|
158
|
+
***Default:*** A random integer between 0 and 1,000,000 generated at runtime.
|
|
159
|
+
|
|
160
|
+
## Record Test Runtimes
|
|
161
|
+
|
|
162
|
+
This option enables or disables pytest_sort to record test case runtimes. These runtimes are used when sort mode is "fastest". When sort mode is "fastest" recording is enabled by default, otherwise this is disabled by default.
|
|
163
|
+
|
|
164
|
+
***Command Line:*** `--sort-record-times/--sort-no-record-times`
|
|
165
|
+
|
|
166
|
+
***Pytest Config:*** `sort_record_times`
|
|
167
|
+
|
|
168
|
+
***Default:*** false
|
|
169
|
+
|
|
170
|
+
| Option | Definition |
|
|
171
|
+
| --- | --- |
|
|
172
|
+
| `--sort-record-times`<br>`sort_record_times=true` | Record test case runtime statistics |
|
|
173
|
+
| `--sort-no-record-times`<br>`sort_record_times=false` | Disable recording runtime statistics in "fastest" mode |
|
|
174
|
+
|
|
175
|
+
## Reset Recorded Test Runtimes
|
|
176
|
+
|
|
177
|
+
Clear all recorded runtimes before sorting the next test.
|
|
178
|
+
|
|
179
|
+
When recording runtimes, only the highest runtime values for each test case are retained. After significant changes to test cases that can change how fast they run, it is advisable to reset the runtimes. This can help maintain more accurate sorting in "fastest" mode.
|
|
180
|
+
|
|
181
|
+
***Command Line:*** `--sort-reset-times`
|
|
182
|
+
|
|
183
|
+
***Pytest Config:*** N/A
|
|
184
|
+
|
|
185
|
+
## Report Recorded Test Runtimes
|
|
186
|
+
|
|
187
|
+
At the end of the test run, print out the currently saved test runtimes.
|
|
188
|
+
|
|
189
|
+
***Command Line:*** `--sort-reset-times`
|
|
190
|
+
|
|
191
|
+
***Pytest Config:*** N/A
|
pytest-sort-0.0.2/PKG-INFO
DELETED
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.1
|
|
2
|
-
Name: pytest-sort
|
|
3
|
-
Version: 0.0.2
|
|
4
|
-
Summary: Tools for sorting test cases
|
|
5
|
-
Author-email: Peter Busch <pbuschmail-pytestsort@yahoo.com>
|
|
6
|
-
Maintainer-email: Peter Busch <pbuschmail-pytestsort@yahoo.com>
|
|
7
|
-
License: MIT License
|
|
8
|
-
|
|
9
|
-
Copyright (c) 2023 Peter Busch
|
|
10
|
-
|
|
11
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
12
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
13
|
-
in the Software without restriction, including without limitation the rights
|
|
14
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
15
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
16
|
-
furnished to do so, subject to the following conditions:
|
|
17
|
-
|
|
18
|
-
The above copyright notice and this permission notice shall be included in all
|
|
19
|
-
copies or substantial portions of the Software.
|
|
20
|
-
|
|
21
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
22
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
23
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
24
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
25
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
26
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
27
|
-
SOFTWARE.
|
|
28
|
-
|
|
29
|
-
Project-URL: Homepage, https://github.com/WiredNerd/pytest-sort
|
|
30
|
-
Project-URL: Bug Tracker, https://github.com/WiredNerd/pytest-sort/issues
|
|
31
|
-
Keywords: test,pytest,order,sort,random,randomly
|
|
32
|
-
Classifier: Programming Language :: Python :: 3
|
|
33
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
34
|
-
Classifier: Operating System :: OS Independent
|
|
35
|
-
Classifier: Framework :: Pytest
|
|
36
|
-
Requires-Python: >=3.8
|
|
37
|
-
Description-Content-Type: text/markdown
|
|
38
|
-
License-File: LICENSE
|
|
39
|
-
|
|
40
|
-

|
|
41
|
-
|
|
42
|
-
## Project description
|
|
43
|
-
|
|
44
|
-
pytest-sort is a pytest plugin to automatically change the execution order of test cases. Changing the order of execution can help find test cases that only succeed because of a favorable state.
|
|
45
|
-
|
|
46
|
-
This plugin provides several options for controlling how the test cases are reordered.
|
|
47
|
-
|
|
48
|
-
## Quick Start
|
|
49
|
-
|
|
50
|
-
Installation:
|
|
51
|
-
|
|
52
|
-
```
|
|
53
|
-
pip install pytest-sort --upgrade
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
Running with pytest-sort:
|
|
57
|
-
|
|
58
|
-
```
|
|
59
|
-
pytest --sort_mode=random
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
By default, all tests from the same module will run together. This command will run the tests within the module in a random order.
|
|
63
|
-
|
|
64
|
-
```
|
|
65
|
-
pytest --help
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
In the pytest-sort section, all currently avaialable options will be listed.
|
|
69
|
-
|
|
70
|
-
You may also set options in any [pytest configruation file](https://docs.pytest.org/en/stable/reference/customize.html).
|
|
71
|
-
|
|
72
|
-
## Options
|
|
73
|
-
|
|
74
|
-
### Sort Bucket
|
|
75
|
-
|
|
76
|
-
***Default:*** module
|
|
77
|
-
|
|
78
|
-
This option controls the scope of the sort operation. For example, if the sort bucket is "module", then all tests from the same module will run together. If the sort bucket is global, than all tests are sorted together.
|
|
79
|
-
|
|
80
|
-
Example:
|
|
81
|
-
```
|
|
82
|
-
pytest --sort_bucket=package
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
| sort_bucket | Definition |
|
|
86
|
-
| --- | --- |
|
|
87
|
-
| global | Apply sort to all items together |
|
|
88
|
-
| package | Group together test cases that are in the same package (folder) |
|
|
89
|
-
| module | Group together test cases that are in the same module (py file) |
|
|
90
|
-
| class | Group together test cases that are members of a class. All other test cases are grouped by module |
|
|
91
|
-
| parent | Group together test cases by their immediate parent |
|
|
92
|
-
| grandparent | Group together test cases by their parent's parent |
|
|
93
|
-
|
|
94
|
-
### Sort Mode
|
|
95
|
-
|
|
96
|
-
***Default:*** none
|
|
97
|
-
|
|
98
|
-
This option controlls how the order is modified within the bucket.
|
|
99
|
-
|
|
100
|
-
Example:
|
|
101
|
-
```
|
|
102
|
-
pytest --sort_mode=md5
|
|
103
|
-
```
|
|
104
|
-
|
|
105
|
-
| sort_mode | Definition |
|
|
106
|
-
| --- | --- |
|
|
107
|
-
| none | pytest_sort will not modify the sort order. This option disables pytest_sort. |
|
|
108
|
-
| md5 | This mode creates an md5 of each test case id, then sorts on those values. <br> This runs test cases in a deterministicly shuffled order. |
|
|
109
|
-
| random | Test cases are shuffled randomly |
|
|
110
|
-
| fastest | In each run in "fasttest" mode, the plugin will track the longest execution time for each test case in a file '.pytest-sort'. <br> At the beginning of a test run, any previously recorded values will be used to sort the tests so that the fastest test runs first.<br> This is intended for use with "-x" or "--exitfirst"
|
pytest-sort-0.0.2/README.md
DELETED
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-

|
|
2
|
-
|
|
3
|
-
## Project description
|
|
4
|
-
|
|
5
|
-
pytest-sort is a pytest plugin to automatically change the execution order of test cases. Changing the order of execution can help find test cases that only succeed because of a favorable state.
|
|
6
|
-
|
|
7
|
-
This plugin provides several options for controlling how the test cases are reordered.
|
|
8
|
-
|
|
9
|
-
## Quick Start
|
|
10
|
-
|
|
11
|
-
Installation:
|
|
12
|
-
|
|
13
|
-
```
|
|
14
|
-
pip install pytest-sort --upgrade
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
Running with pytest-sort:
|
|
18
|
-
|
|
19
|
-
```
|
|
20
|
-
pytest --sort_mode=random
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
By default, all tests from the same module will run together. This command will run the tests within the module in a random order.
|
|
24
|
-
|
|
25
|
-
```
|
|
26
|
-
pytest --help
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
In the pytest-sort section, all currently avaialable options will be listed.
|
|
30
|
-
|
|
31
|
-
You may also set options in any [pytest configruation file](https://docs.pytest.org/en/stable/reference/customize.html).
|
|
32
|
-
|
|
33
|
-
## Options
|
|
34
|
-
|
|
35
|
-
### Sort Bucket
|
|
36
|
-
|
|
37
|
-
***Default:*** module
|
|
38
|
-
|
|
39
|
-
This option controls the scope of the sort operation. For example, if the sort bucket is "module", then all tests from the same module will run together. If the sort bucket is global, than all tests are sorted together.
|
|
40
|
-
|
|
41
|
-
Example:
|
|
42
|
-
```
|
|
43
|
-
pytest --sort_bucket=package
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
| sort_bucket | Definition |
|
|
47
|
-
| --- | --- |
|
|
48
|
-
| global | Apply sort to all items together |
|
|
49
|
-
| package | Group together test cases that are in the same package (folder) |
|
|
50
|
-
| module | Group together test cases that are in the same module (py file) |
|
|
51
|
-
| class | Group together test cases that are members of a class. All other test cases are grouped by module |
|
|
52
|
-
| parent | Group together test cases by their immediate parent |
|
|
53
|
-
| grandparent | Group together test cases by their parent's parent |
|
|
54
|
-
|
|
55
|
-
### Sort Mode
|
|
56
|
-
|
|
57
|
-
***Default:*** none
|
|
58
|
-
|
|
59
|
-
This option controlls how the order is modified within the bucket.
|
|
60
|
-
|
|
61
|
-
Example:
|
|
62
|
-
```
|
|
63
|
-
pytest --sort_mode=md5
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
| sort_mode | Definition |
|
|
67
|
-
| --- | --- |
|
|
68
|
-
| none | pytest_sort will not modify the sort order. This option disables pytest_sort. |
|
|
69
|
-
| md5 | This mode creates an md5 of each test case id, then sorts on those values. <br> This runs test cases in a deterministicly shuffled order. |
|
|
70
|
-
| random | Test cases are shuffled randomly |
|
|
71
|
-
| fastest | In each run in "fasttest" mode, the plugin will track the longest execution time for each test case in a file '.pytest-sort'. <br> At the beginning of a test run, any previously recorded values will be used to sort the tests so that the fastest test runs first.<br> This is intended for use with "-x" or "--exitfirst"
|
|
@@ -1,110 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.1
|
|
2
|
-
Name: pytest-sort
|
|
3
|
-
Version: 0.0.2
|
|
4
|
-
Summary: Tools for sorting test cases
|
|
5
|
-
Author-email: Peter Busch <pbuschmail-pytestsort@yahoo.com>
|
|
6
|
-
Maintainer-email: Peter Busch <pbuschmail-pytestsort@yahoo.com>
|
|
7
|
-
License: MIT License
|
|
8
|
-
|
|
9
|
-
Copyright (c) 2023 Peter Busch
|
|
10
|
-
|
|
11
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
12
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
13
|
-
in the Software without restriction, including without limitation the rights
|
|
14
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
15
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
16
|
-
furnished to do so, subject to the following conditions:
|
|
17
|
-
|
|
18
|
-
The above copyright notice and this permission notice shall be included in all
|
|
19
|
-
copies or substantial portions of the Software.
|
|
20
|
-
|
|
21
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
22
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
23
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
24
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
25
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
26
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
27
|
-
SOFTWARE.
|
|
28
|
-
|
|
29
|
-
Project-URL: Homepage, https://github.com/WiredNerd/pytest-sort
|
|
30
|
-
Project-URL: Bug Tracker, https://github.com/WiredNerd/pytest-sort/issues
|
|
31
|
-
Keywords: test,pytest,order,sort,random,randomly
|
|
32
|
-
Classifier: Programming Language :: Python :: 3
|
|
33
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
34
|
-
Classifier: Operating System :: OS Independent
|
|
35
|
-
Classifier: Framework :: Pytest
|
|
36
|
-
Requires-Python: >=3.8
|
|
37
|
-
Description-Content-Type: text/markdown
|
|
38
|
-
License-File: LICENSE
|
|
39
|
-
|
|
40
|
-

|
|
41
|
-
|
|
42
|
-
## Project description
|
|
43
|
-
|
|
44
|
-
pytest-sort is a pytest plugin to automatically change the execution order of test cases. Changing the order of execution can help find test cases that only succeed because of a favorable state.
|
|
45
|
-
|
|
46
|
-
This plugin provides several options for controlling how the test cases are reordered.
|
|
47
|
-
|
|
48
|
-
## Quick Start
|
|
49
|
-
|
|
50
|
-
Installation:
|
|
51
|
-
|
|
52
|
-
```
|
|
53
|
-
pip install pytest-sort --upgrade
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
Running with pytest-sort:
|
|
57
|
-
|
|
58
|
-
```
|
|
59
|
-
pytest --sort_mode=random
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
By default, all tests from the same module will run together. This command will run the tests within the module in a random order.
|
|
63
|
-
|
|
64
|
-
```
|
|
65
|
-
pytest --help
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
In the pytest-sort section, all currently avaialable options will be listed.
|
|
69
|
-
|
|
70
|
-
You may also set options in any [pytest configruation file](https://docs.pytest.org/en/stable/reference/customize.html).
|
|
71
|
-
|
|
72
|
-
## Options
|
|
73
|
-
|
|
74
|
-
### Sort Bucket
|
|
75
|
-
|
|
76
|
-
***Default:*** module
|
|
77
|
-
|
|
78
|
-
This option controls the scope of the sort operation. For example, if the sort bucket is "module", then all tests from the same module will run together. If the sort bucket is global, than all tests are sorted together.
|
|
79
|
-
|
|
80
|
-
Example:
|
|
81
|
-
```
|
|
82
|
-
pytest --sort_bucket=package
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
| sort_bucket | Definition |
|
|
86
|
-
| --- | --- |
|
|
87
|
-
| global | Apply sort to all items together |
|
|
88
|
-
| package | Group together test cases that are in the same package (folder) |
|
|
89
|
-
| module | Group together test cases that are in the same module (py file) |
|
|
90
|
-
| class | Group together test cases that are members of a class. All other test cases are grouped by module |
|
|
91
|
-
| parent | Group together test cases by their immediate parent |
|
|
92
|
-
| grandparent | Group together test cases by their parent's parent |
|
|
93
|
-
|
|
94
|
-
### Sort Mode
|
|
95
|
-
|
|
96
|
-
***Default:*** none
|
|
97
|
-
|
|
98
|
-
This option controlls how the order is modified within the bucket.
|
|
99
|
-
|
|
100
|
-
Example:
|
|
101
|
-
```
|
|
102
|
-
pytest --sort_mode=md5
|
|
103
|
-
```
|
|
104
|
-
|
|
105
|
-
| sort_mode | Definition |
|
|
106
|
-
| --- | --- |
|
|
107
|
-
| none | pytest_sort will not modify the sort order. This option disables pytest_sort. |
|
|
108
|
-
| md5 | This mode creates an md5 of each test case id, then sorts on those values. <br> This runs test cases in a deterministicly shuffled order. |
|
|
109
|
-
| random | Test cases are shuffled randomly |
|
|
110
|
-
| fastest | In each run in "fasttest" mode, the plugin will track the longest execution time for each test case in a file '.pytest-sort'. <br> At the beginning of a test run, any previously recorded values will be used to sort the tests so that the fastest test runs first.<br> This is intended for use with "-x" or "--exitfirst"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|