pytest-sort 1.3.2__tar.gz → 1.3.4__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-1.3.2/src/pytest_sort.egg-info → pytest_sort-1.3.4}/PKG-INFO +4 -3
- {pytest_sort-1.3.2 → pytest_sort-1.3.4}/README.md +2 -2
- {pytest_sort-1.3.2 → pytest_sort-1.3.4}/pyproject.toml +7 -5
- {pytest_sort-1.3.2 → pytest_sort-1.3.4}/src/pytest_sort/__init__.py +2 -0
- {pytest_sort-1.3.2 → pytest_sort-1.3.4}/src/pytest_sort/config.py +2 -0
- {pytest_sort-1.3.2 → pytest_sort-1.3.4}/src/pytest_sort/core.py +16 -8
- {pytest_sort-1.3.2 → pytest_sort-1.3.4}/src/pytest_sort/database.py +2 -0
- {pytest_sort-1.3.2 → pytest_sort-1.3.4}/src/pytest_sort/diffcov.py +3 -1
- {pytest_sort-1.3.2 → pytest_sort-1.3.4}/src/pytest_sort/plugin.py +8 -6
- {pytest_sort-1.3.2 → pytest_sort-1.3.4/src/pytest_sort.egg-info}/PKG-INFO +4 -3
- {pytest_sort-1.3.2 → pytest_sort-1.3.4}/src/pytest_sort.egg-info/requires.txt +1 -0
- {pytest_sort-1.3.2 → pytest_sort-1.3.4}/test/test_config.py +7 -5
- {pytest_sort-1.3.2 → pytest_sort-1.3.4}/test/test_core.py +38 -28
- {pytest_sort-1.3.2 → pytest_sort-1.3.4}/test/test_database.py +2 -0
- {pytest_sort-1.3.2 → pytest_sort-1.3.4}/test/test_diffcov.py +2 -0
- {pytest_sort-1.3.2 → pytest_sort-1.3.4}/test/test_plugin.py +2 -0
- {pytest_sort-1.3.2 → pytest_sort-1.3.4}/LICENSE +0 -0
- {pytest_sort-1.3.2 → pytest_sort-1.3.4}/setup.cfg +0 -0
- {pytest_sort-1.3.2 → pytest_sort-1.3.4}/src/pytest_sort.egg-info/SOURCES.txt +0 -0
- {pytest_sort-1.3.2 → pytest_sort-1.3.4}/src/pytest_sort.egg-info/dependency_links.txt +0 -0
- {pytest_sort-1.3.2 → pytest_sort-1.3.4}/src/pytest_sort.egg-info/entry_points.txt +0 -0
- {pytest_sort-1.3.2 → pytest_sort-1.3.4}/src/pytest_sort.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pytest-sort
|
|
3
|
-
Version: 1.3.
|
|
3
|
+
Version: 1.3.4
|
|
4
4
|
Summary: Tools for sorting test cases
|
|
5
5
|
Author-email: WiredNerd <pbuschmail-pytestsort@yahoo.com>
|
|
6
6
|
Maintainer-email: WiredNerd <pbuschmail-pytestsort@yahoo.com>
|
|
@@ -34,16 +34,17 @@ Classifier: Programming Language :: Python :: 3
|
|
|
34
34
|
Classifier: License :: OSI Approved :: MIT License
|
|
35
35
|
Classifier: Operating System :: OS Independent
|
|
36
36
|
Classifier: Framework :: Pytest
|
|
37
|
-
Requires-Python: >=3.
|
|
37
|
+
Requires-Python: >=3.11
|
|
38
38
|
Description-Content-Type: text/markdown
|
|
39
39
|
License-File: LICENSE
|
|
40
40
|
Requires-Dist: pytest>=7.4.0
|
|
41
41
|
Requires-Dist: whatthepatch>=1.0.5
|
|
42
42
|
Requires-Dist: coverage>=7.3.1
|
|
43
|
+
Requires-Dist: zipp>=3.19.1
|
|
43
44
|
Dynamic: license-file
|
|
44
45
|
|
|
45
46
|
[](https://github.com/WiredNerd/pytest-sort)
|
|
46
|
-
[](https://pypi.org/project/pytest-sort)
|
|
47
48
|
[](https://pypi.org/project/pytest-sort)
|
|
48
49
|
[](https://pypistats.org/packages/pytest-sort)
|
|
49
50
|
[](https://github.com/WiredNerd/pytest-sort/blob/main/LICENSE)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
[](https://github.com/WiredNerd/pytest-sort)
|
|
2
|
-
[](https://pypi.org/project/pytest-sort)
|
|
3
3
|
[](https://pypi.org/project/pytest-sort)
|
|
4
4
|
[](https://pypistats.org/packages/pytest-sort)
|
|
5
5
|
[](https://github.com/WiredNerd/pytest-sort/blob/main/LICENSE)
|
|
@@ -61,4 +61,4 @@ Or by opening an issue: https://github.com/WiredNerd/pytest-sort/issues
|
|
|
61
61
|
|
|
62
62
|
## License
|
|
63
63
|
|
|
64
|
-
The project is licensed under the MIT license.
|
|
64
|
+
The project is licensed under the MIT license.
|
|
@@ -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 = "1.3.
|
|
8
|
+
version = "1.3.4"
|
|
9
9
|
license = { file = "LICENSE" }
|
|
10
10
|
keywords = [
|
|
11
11
|
"test",
|
|
@@ -24,14 +24,14 @@ maintainers = [
|
|
|
24
24
|
{ name = "WiredNerd", email = "pbuschmail-pytestsort@yahoo.com" },
|
|
25
25
|
]
|
|
26
26
|
readme = "README.md"
|
|
27
|
-
requires-python = ">=3.
|
|
27
|
+
requires-python = ">=3.11"
|
|
28
28
|
classifiers = [
|
|
29
29
|
"Programming Language :: Python :: 3",
|
|
30
30
|
"License :: OSI Approved :: MIT License",
|
|
31
31
|
"Operating System :: OS Independent",
|
|
32
32
|
"Framework :: Pytest",
|
|
33
33
|
]
|
|
34
|
-
dependencies = ["pytest>=7.4.0", "whatthepatch>=1.0.5", "coverage>=7.3.1"]
|
|
34
|
+
dependencies = ["pytest>=7.4.0", "whatthepatch>=1.0.5", "coverage>=7.3.1", "zipp>=3.19.1"]
|
|
35
35
|
|
|
36
36
|
[project.urls]
|
|
37
37
|
"Documentation" = "https://pytest-sort.readthedocs.io/"
|
|
@@ -64,7 +64,7 @@ command_line = "pytest -x --assert=plain -o pythonpath='{PYTHONPATH}' --sort-mod
|
|
|
64
64
|
|
|
65
65
|
[tool.black]
|
|
66
66
|
line-length = 120
|
|
67
|
-
target-version = ['
|
|
67
|
+
target-version = ['py311', 'py312', 'py313', 'py314', 'py315']
|
|
68
68
|
skip-string-normalization = true
|
|
69
69
|
color = true
|
|
70
70
|
|
|
@@ -76,7 +76,7 @@ files = "src"
|
|
|
76
76
|
mypy_path = "src"
|
|
77
77
|
|
|
78
78
|
[tool.ruff]
|
|
79
|
-
target-version = "
|
|
79
|
+
target-version = "py311"
|
|
80
80
|
output-format = "full"
|
|
81
81
|
line-length = 120
|
|
82
82
|
exclude = [
|
|
@@ -137,7 +137,9 @@ known-first-party = ["pytest_sort"]
|
|
|
137
137
|
"N802", # Function name should be lowercase
|
|
138
138
|
"N803", # Argument name should be lowercase
|
|
139
139
|
"PLR0913", # Too many arguments in function definition
|
|
140
|
+
"PLR0917", # Too many positional arguments
|
|
140
141
|
"PLR2004", # Magic value used in comparison
|
|
141
142
|
"S101", # Use of `assert` detected
|
|
142
143
|
"SLF001", # Private member accessed
|
|
144
|
+
"RUF059", # Unpacked variable is never used
|
|
143
145
|
]
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# Copyright (c) 2023 WiredNerd
|
|
2
|
+
# SPDX-License-Identifier: MIT
|
|
1
3
|
"""Core logic for pytest_sort plugin."""
|
|
2
4
|
|
|
3
5
|
from __future__ import annotations
|
|
@@ -5,7 +7,7 @@ from __future__ import annotations
|
|
|
5
7
|
import hashlib
|
|
6
8
|
import random
|
|
7
9
|
from functools import partial
|
|
8
|
-
from typing import TYPE_CHECKING, Any
|
|
10
|
+
from typing import TYPE_CHECKING, Any
|
|
9
11
|
|
|
10
12
|
import pytest
|
|
11
13
|
from _pytest import nodes as pytest_nodes
|
|
@@ -14,12 +16,18 @@ from pytest_sort.config import SortConfig
|
|
|
14
16
|
from pytest_sort.database import get_all_totals, get_stats
|
|
15
17
|
from pytest_sort.diffcov import get_diff_test_scores, get_mut_test_scores
|
|
16
18
|
|
|
17
|
-
md5: Callable = partial(hashlib.md5, usedforsecurity=False) # type: ignore[no-redef]
|
|
18
|
-
|
|
19
|
-
|
|
20
19
|
if TYPE_CHECKING:
|
|
20
|
+
import sys
|
|
21
|
+
|
|
21
22
|
from _pytest.terminal import TerminalReporter
|
|
22
23
|
|
|
24
|
+
if sys.version_info < (3, 14): # nomut
|
|
25
|
+
from typing import Callable # noqa: UP035 # pragma: no cover
|
|
26
|
+
else:
|
|
27
|
+
from collections.abc import Callable
|
|
28
|
+
|
|
29
|
+
md5: Callable = partial(hashlib.md5, usedforsecurity=False) # type: ignore[no-redef]
|
|
30
|
+
|
|
23
31
|
|
|
24
32
|
def create_bucket_id_from_node(node: pytest_nodes.Node | None) -> str:
|
|
25
33
|
"""Extract portion of nodeid needed for bucket key."""
|
|
@@ -138,7 +146,7 @@ def validate_sort_marker(sort_marker: pytest.Mark, node_id: str) -> tuple:
|
|
|
138
146
|
return (mode, bucket)
|
|
139
147
|
|
|
140
148
|
try:
|
|
141
|
-
|
|
149
|
+
mode, bucket_temp = mark_sort_parse(*sort_marker.args, **sort_marker.kwargs)
|
|
142
150
|
except TypeError as e:
|
|
143
151
|
msg = f"Incorrect arguments on marker 'sort'. Target:{node_id}"
|
|
144
152
|
raise TypeError(msg) from e
|
|
@@ -166,7 +174,7 @@ def get_marker_settings(node: pytest_nodes.Node) -> tuple:
|
|
|
166
174
|
node_id = node.nodeid
|
|
167
175
|
|
|
168
176
|
if node.parent:
|
|
169
|
-
|
|
177
|
+
mode, bucket, bucket_id, bucket_sort_key, item_sort_key = get_marker_settings(node.parent)
|
|
170
178
|
|
|
171
179
|
for order in node.iter_markers("order"):
|
|
172
180
|
sort_key = validate_order_marker(order, node_id)
|
|
@@ -177,7 +185,7 @@ def get_marker_settings(node: pytest_nodes.Node) -> tuple:
|
|
|
177
185
|
bucket_id = create_bucket_id_from_node(node)
|
|
178
186
|
|
|
179
187
|
for sort in node.iter_markers("sort"):
|
|
180
|
-
|
|
188
|
+
mode, bucket_temp = validate_sort_marker(sort, node_id)
|
|
181
189
|
|
|
182
190
|
if bucket_temp == "self":
|
|
183
191
|
bucket_id = create_bucket_id_from_node(node)
|
|
@@ -197,7 +205,7 @@ def create_sort_keys(item: pytest.Item, idx: int, count: int) -> None:
|
|
|
197
205
|
|
|
198
206
|
Store in SortConfig.item_sort_keys and SortConfig.bucket_sort_keys
|
|
199
207
|
"""
|
|
200
|
-
|
|
208
|
+
mode, bucket, bucket_id, bucket_sort_key, item_sort_key = get_marker_settings(item)
|
|
201
209
|
|
|
202
210
|
SortConfig.item_sort_keys[item.nodeid] = item_sort_key or create_item_key[mode or SortConfig.mode](item, idx, count)
|
|
203
211
|
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# Copyright (c) 2023 WiredNerd
|
|
2
|
+
# SPDX-License-Identifier: MIT
|
|
1
3
|
"""Logic for prioritizing tests by coverage of changes."""
|
|
2
4
|
|
|
3
5
|
from __future__ import annotations
|
|
@@ -76,7 +78,7 @@ def get_line_coverage() -> Generator[tuple[Path, str, str, int], Any, None]:
|
|
|
76
78
|
for test in tests:
|
|
77
79
|
match = PARSE_TEST_CONTEXT.search(test)
|
|
78
80
|
if match:
|
|
79
|
-
|
|
81
|
+
nodeid, when = match.group("nodeid", "when")
|
|
80
82
|
yield rpath, nodeid, when, line
|
|
81
83
|
|
|
82
84
|
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# Copyright (c) 2023 WiredNerd
|
|
2
|
+
# SPDX-License-Identifier: MIT
|
|
1
3
|
"""Pytest plugin code for pytest_sort."""
|
|
2
4
|
|
|
3
5
|
from __future__ import annotations
|
|
@@ -17,7 +19,7 @@ if TYPE_CHECKING:
|
|
|
17
19
|
from _pytest.terminal import TerminalReporter
|
|
18
20
|
|
|
19
21
|
|
|
20
|
-
@pytest.hookimpl
|
|
22
|
+
@pytest.hookimpl # nomut: Decorator
|
|
21
23
|
def pytest_addoption(parser: pytest.Parser) -> None:
|
|
22
24
|
"""pytest_sort: Add command line and ini options to pytest."""
|
|
23
25
|
group = parser.getgroup("pytest-sort")
|
|
@@ -65,7 +67,7 @@ def pytest_addoption(parser: pytest.Parser) -> None:
|
|
|
65
67
|
group.addoption("--sort_debug", action="store_true", dest="sort_debug", help=argparse.SUPPRESS)
|
|
66
68
|
|
|
67
69
|
|
|
68
|
-
@pytest.hookimpl
|
|
70
|
+
@pytest.hookimpl # nomut: Decorator
|
|
69
71
|
def pytest_configure(config: pytest.Config) -> None:
|
|
70
72
|
"""pytest_sort: Add markers to pytest."""
|
|
71
73
|
config.addinivalue_line(
|
|
@@ -80,7 +82,7 @@ def pytest_configure(config: pytest.Config) -> None:
|
|
|
80
82
|
SortConfig.from_pytest(config)
|
|
81
83
|
|
|
82
84
|
|
|
83
|
-
@pytest.hookimpl
|
|
85
|
+
@pytest.hookimpl # nomut: Decorator
|
|
84
86
|
def pytest_report_header(config: pytest.Config) -> str: # noqa: ARG001
|
|
85
87
|
"""pytest_sort: Build Header for pytest to display."""
|
|
86
88
|
header = "pytest-sort:"
|
|
@@ -91,7 +93,7 @@ def pytest_report_header(config: pytest.Config) -> str: # noqa: ARG001
|
|
|
91
93
|
return header
|
|
92
94
|
|
|
93
95
|
|
|
94
|
-
@pytest.hookimpl
|
|
96
|
+
@pytest.hookimpl # nomut: Decorator
|
|
95
97
|
def pytest_collection_modifyitems(
|
|
96
98
|
session: pytest.Session, # noqa: ARG001
|
|
97
99
|
config: pytest.Config, # noqa: ARG001
|
|
@@ -104,7 +106,7 @@ def pytest_collection_modifyitems(
|
|
|
104
106
|
sort_items(items)
|
|
105
107
|
|
|
106
108
|
|
|
107
|
-
@pytest.hookimpl(hookwrapper=True) #
|
|
109
|
+
@pytest.hookimpl(hookwrapper=True) # nomut
|
|
108
110
|
def pytest_runtest_makereport(item: pytest.Item, call: pytest.CallInfo) -> Generator:
|
|
109
111
|
"""pytest_sort: Record test runtimes in memory."""
|
|
110
112
|
if SortConfig.record and call.when in ("setup", "call", "teardown"):
|
|
@@ -118,7 +120,7 @@ def pytest_runtest_makereport(item: pytest.Item, call: pytest.CallInfo) -> Gener
|
|
|
118
120
|
yield
|
|
119
121
|
|
|
120
122
|
|
|
121
|
-
@pytest.hookimpl
|
|
123
|
+
@pytest.hookimpl # nomut: Decorator
|
|
122
124
|
def pytest_terminal_summary(
|
|
123
125
|
terminalreporter: TerminalReporter,
|
|
124
126
|
exitstatus: int, # noqa: ARG001
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pytest-sort
|
|
3
|
-
Version: 1.3.
|
|
3
|
+
Version: 1.3.4
|
|
4
4
|
Summary: Tools for sorting test cases
|
|
5
5
|
Author-email: WiredNerd <pbuschmail-pytestsort@yahoo.com>
|
|
6
6
|
Maintainer-email: WiredNerd <pbuschmail-pytestsort@yahoo.com>
|
|
@@ -34,16 +34,17 @@ Classifier: Programming Language :: Python :: 3
|
|
|
34
34
|
Classifier: License :: OSI Approved :: MIT License
|
|
35
35
|
Classifier: Operating System :: OS Independent
|
|
36
36
|
Classifier: Framework :: Pytest
|
|
37
|
-
Requires-Python: >=3.
|
|
37
|
+
Requires-Python: >=3.11
|
|
38
38
|
Description-Content-Type: text/markdown
|
|
39
39
|
License-File: LICENSE
|
|
40
40
|
Requires-Dist: pytest>=7.4.0
|
|
41
41
|
Requires-Dist: whatthepatch>=1.0.5
|
|
42
42
|
Requires-Dist: coverage>=7.3.1
|
|
43
|
+
Requires-Dist: zipp>=3.19.1
|
|
43
44
|
Dynamic: license-file
|
|
44
45
|
|
|
45
46
|
[](https://github.com/WiredNerd/pytest-sort)
|
|
46
|
-
[](https://pypi.org/project/pytest-sort)
|
|
47
48
|
[](https://pypi.org/project/pytest-sort)
|
|
48
49
|
[](https://pypistats.org/packages/pytest-sort)
|
|
49
50
|
[](https://github.com/WiredNerd/pytest-sort/blob/main/LICENSE)
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# Copyright (c) 2023 WiredNerd
|
|
2
|
+
# SPDX-License-Identifier: MIT
|
|
1
3
|
import importlib
|
|
2
4
|
import random
|
|
3
5
|
import sys
|
|
@@ -104,7 +106,7 @@ class TestSortConfig:
|
|
|
104
106
|
|
|
105
107
|
def test_from_pytest_mode_invalid(self):
|
|
106
108
|
pytest_config = self.PytestConfig({"sort_mode": "September"}, {})
|
|
107
|
-
with pytest.raises(ValueError, match="^Invalid Value for sort-mode='September'$"):
|
|
109
|
+
with pytest.raises(ValueError, match=r"^Invalid Value for sort-mode='September'$"):
|
|
108
110
|
config.SortConfig.from_pytest(pytest_config)
|
|
109
111
|
|
|
110
112
|
@pytest.mark.parametrize(
|
|
@@ -128,7 +130,7 @@ class TestSortConfig:
|
|
|
128
130
|
|
|
129
131
|
def test_from_pytest_bucket_invalid(self):
|
|
130
132
|
pytest_config = self.PytestConfig({"sort_bucket": "September"}, {})
|
|
131
|
-
with pytest.raises(ValueError, match="^Invalid Value for sort-bucket='September'$"):
|
|
133
|
+
with pytest.raises(ValueError, match=r"^Invalid Value for sort-bucket='September'$"):
|
|
132
134
|
config.SortConfig.from_pytest(pytest_config)
|
|
133
135
|
|
|
134
136
|
@pytest.mark.parametrize(
|
|
@@ -155,12 +157,12 @@ class TestSortConfig:
|
|
|
155
157
|
|
|
156
158
|
def test_from_pytest_bucket_mode_invalid(self):
|
|
157
159
|
pytest_config = self.PytestConfig({"sort_bucket_mode": "September"}, {})
|
|
158
|
-
with pytest.raises(ValueError, match="^Invalid Value for sort-bucket-mode='September'$"):
|
|
160
|
+
with pytest.raises(ValueError, match=r"^Invalid Value for sort-bucket-mode='September'$"):
|
|
159
161
|
config.SortConfig.from_pytest(pytest_config)
|
|
160
162
|
|
|
161
163
|
def test_from_pytest_sort_record_conflict(self):
|
|
162
164
|
pytest_config = self.PytestConfig({"sort_no_record": True, "sort_record": True}, {})
|
|
163
|
-
with pytest.raises(ValueError, match="^Do not use both --sort-record-times and --sort-no-record-times$"):
|
|
165
|
+
with pytest.raises(ValueError, match=r"^Do not use both --sort-record-times and --sort-no-record-times$"):
|
|
164
166
|
config.SortConfig.from_pytest(pytest_config)
|
|
165
167
|
|
|
166
168
|
@pytest.mark.parametrize(
|
|
@@ -202,7 +204,7 @@ class TestSortConfig:
|
|
|
202
204
|
|
|
203
205
|
def test_from_pytest_seed_invalid(self):
|
|
204
206
|
pytest_config = self.PytestConfig({}, {"sort_seed": "ABC"})
|
|
205
|
-
with pytest.raises(ValueError, match="^Invalid seed value 'ABC' must be int$"):
|
|
207
|
+
with pytest.raises(ValueError, match=r"^Invalid seed value 'ABC' must be int$"):
|
|
206
208
|
config.SortConfig.from_pytest(pytest_config)
|
|
207
209
|
|
|
208
210
|
@pytest.mark.parametrize(
|
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
# Copyright (c) 2023 WiredNerd
|
|
2
|
+
# SPDX-License-Identifier: MIT
|
|
1
3
|
import hashlib
|
|
2
4
|
import importlib
|
|
5
|
+
import sys
|
|
3
6
|
from functools import partial
|
|
4
|
-
from typing import
|
|
7
|
+
from typing import ClassVar
|
|
5
8
|
from unittest import mock
|
|
6
9
|
|
|
7
10
|
import pytest
|
|
@@ -9,6 +12,11 @@ from _pytest import nodes as pytest_nodes
|
|
|
9
12
|
|
|
10
13
|
from pytest_sort import config, core
|
|
11
14
|
|
|
15
|
+
if sys.version_info < (3, 14): # nomut
|
|
16
|
+
from typing import Callable # noqa: UP035 # pragma: no cover
|
|
17
|
+
else:
|
|
18
|
+
from collections.abc import Callable
|
|
19
|
+
|
|
12
20
|
md5: Callable = partial(hashlib.md5, usedforsecurity=False) # type: ignore[no-redef]
|
|
13
21
|
|
|
14
22
|
|
|
@@ -78,7 +86,7 @@ class TestCreateBucketIdForNode:
|
|
|
78
86
|
assert core.create_bucket_id_from_node(node) == bucket_id
|
|
79
87
|
|
|
80
88
|
def test_create_bucket_id_for_package(self, mock_objects):
|
|
81
|
-
|
|
89
|
+
session, package, module, cls, func = mock_objects
|
|
82
90
|
|
|
83
91
|
assert core.create_bucket_id_for_package(session) == "session"
|
|
84
92
|
assert core.create_bucket_id_for_package(package) == "tests/core/"
|
|
@@ -90,7 +98,7 @@ class TestCreateBucketIdForNode:
|
|
|
90
98
|
assert core.create_bucket_id_for_package(module) == ""
|
|
91
99
|
|
|
92
100
|
def test_create_bucket_id_for_module(self, mock_objects):
|
|
93
|
-
|
|
101
|
+
session, package, module, cls, func = mock_objects
|
|
94
102
|
|
|
95
103
|
assert core.create_bucket_id_for_module(session) == "session"
|
|
96
104
|
assert core.create_bucket_id_for_module(package) == "tests/core/"
|
|
@@ -102,7 +110,7 @@ class TestCreateBucketIdForNode:
|
|
|
102
110
|
assert core.create_bucket_id_for_module(cls) == ""
|
|
103
111
|
|
|
104
112
|
def test_create_bucket_id_for_class(self, mock_objects):
|
|
105
|
-
|
|
113
|
+
session, package, module, cls, func = mock_objects
|
|
106
114
|
|
|
107
115
|
assert core.create_bucket_id_for_class(session) == "session"
|
|
108
116
|
assert core.create_bucket_id_for_class(package) == "tests/core/"
|
|
@@ -116,7 +124,7 @@ class TestCreateBucketIdForNode:
|
|
|
116
124
|
|
|
117
125
|
class TestCreateBucketId:
|
|
118
126
|
def test_create_bucket_id(self, mock_objects):
|
|
119
|
-
|
|
127
|
+
session, package, module, cls, func = mock_objects
|
|
120
128
|
|
|
121
129
|
assert core.create_bucket_id["session"](func) == ""
|
|
122
130
|
assert core.create_bucket_id["package"](func) == "tests/core/"
|
|
@@ -127,7 +135,7 @@ class TestCreateBucketId:
|
|
|
127
135
|
assert core.create_bucket_id["grandparent"](func) == "tests/core/test_core.py"
|
|
128
136
|
|
|
129
137
|
def test_create_item_key(self, mock_objects):
|
|
130
|
-
|
|
138
|
+
session, package, module, cls, func = mock_objects
|
|
131
139
|
|
|
132
140
|
assert core.create_item_key["ordered"](func, 5, 20) == 6
|
|
133
141
|
assert core.create_item_key["reverse"](func, 5, 20) == 15
|
|
@@ -138,21 +146,21 @@ class TestCreateBucketId:
|
|
|
138
146
|
assert 0 <= core.create_item_key["random"](func, 5, 20) < 1
|
|
139
147
|
|
|
140
148
|
def test_create_item_key_fastest(self, mock_objects):
|
|
141
|
-
|
|
149
|
+
session, package, module, cls, func = mock_objects
|
|
142
150
|
|
|
143
151
|
assert core.create_item_key["fastest"](func, 5, 20) == 0
|
|
144
152
|
core.SortConfig.item_totals = {func.nodeid: 123}
|
|
145
153
|
assert core.create_item_key["fastest"](func, 5, 20) == 123
|
|
146
154
|
|
|
147
155
|
def test_create_item_key_diffcov(self, mock_objects):
|
|
148
|
-
|
|
156
|
+
session, package, module, cls, func = mock_objects
|
|
149
157
|
|
|
150
158
|
assert core.create_item_key["diffcov"](func, 5, 20) == 0
|
|
151
159
|
core.SortConfig.diff_cov_scores = {func.nodeid: -123}
|
|
152
160
|
assert core.create_item_key["diffcov"](func, 5, 20) == -123
|
|
153
161
|
|
|
154
162
|
def test_create_item_key_mutcov(self, mock_objects):
|
|
155
|
-
|
|
163
|
+
session, package, module, cls, func = mock_objects
|
|
156
164
|
|
|
157
165
|
assert core.create_item_key["mutcov"](func, 5, 20) == 0
|
|
158
166
|
core.SortConfig.mut_cov_scores = {func.nodeid: -123}
|
|
@@ -218,7 +226,9 @@ class TestValidateMarker:
|
|
|
218
226
|
order_marker.args = []
|
|
219
227
|
order_marker.kwargs = {}
|
|
220
228
|
|
|
221
|
-
with pytest.raises(
|
|
229
|
+
with pytest.raises(
|
|
230
|
+
TypeError, match=r"^Incorrect arguments on marker 'order'. Target:testnodeid$"
|
|
231
|
+
) as type_error:
|
|
222
232
|
core.validate_order_marker(order_marker, "testnodeid")
|
|
223
233
|
|
|
224
234
|
assert isinstance(type_error.value.__cause__, TypeError)
|
|
@@ -244,7 +254,7 @@ class TestValidateMarker:
|
|
|
244
254
|
sort_marker.args = []
|
|
245
255
|
sort_marker.kwargs = {}
|
|
246
256
|
|
|
247
|
-
with pytest.raises(TypeError, match="^Incorrect arguments on marker 'sort'. Target:testnodeid$") as type_error:
|
|
257
|
+
with pytest.raises(TypeError, match=r"^Incorrect arguments on marker 'sort'. Target:testnodeid$") as type_error:
|
|
248
258
|
core.validate_sort_marker(sort_marker, "testnodeid")
|
|
249
259
|
|
|
250
260
|
assert isinstance(type_error.value.__cause__, TypeError)
|
|
@@ -255,7 +265,7 @@ class TestValidateMarker:
|
|
|
255
265
|
sort_marker.kwargs = {}
|
|
256
266
|
|
|
257
267
|
with pytest.raises(
|
|
258
|
-
ValueError, match="^Invalid Value for 'mode' on 'sort' marker. Value:invalid Target:testnodeid$"
|
|
268
|
+
ValueError, match=r"^Invalid Value for 'mode' on 'sort' marker. Value:invalid Target:testnodeid$"
|
|
259
269
|
) as type_error:
|
|
260
270
|
core.validate_sort_marker(sort_marker, "testnodeid")
|
|
261
271
|
|
|
@@ -264,7 +274,7 @@ class TestValidateMarker:
|
|
|
264
274
|
|
|
265
275
|
class TestMarkerSettings:
|
|
266
276
|
def test_get_marker_settings_order_function(self, mock_objects):
|
|
267
|
-
|
|
277
|
+
session, package, module, cls, func = mock_objects
|
|
268
278
|
|
|
269
279
|
order_1 = mock.MagicMock()
|
|
270
280
|
order_1.args = [1]
|
|
@@ -282,7 +292,7 @@ class TestMarkerSettings:
|
|
|
282
292
|
)
|
|
283
293
|
|
|
284
294
|
def test_get_marker_settings_order_cls(self, mock_objects):
|
|
285
|
-
|
|
295
|
+
session, package, module, cls, func = mock_objects
|
|
286
296
|
|
|
287
297
|
order_1 = mock.MagicMock()
|
|
288
298
|
order_1.args = [1]
|
|
@@ -305,7 +315,7 @@ class TestMarkerSettings:
|
|
|
305
315
|
)
|
|
306
316
|
|
|
307
317
|
def test_get_marker_settings_order_mod(self, mock_objects):
|
|
308
|
-
|
|
318
|
+
session, package, module, cls, func = mock_objects
|
|
309
319
|
|
|
310
320
|
order_1 = mock.MagicMock()
|
|
311
321
|
order_1.args = [1]
|
|
@@ -328,7 +338,7 @@ class TestMarkerSettings:
|
|
|
328
338
|
)
|
|
329
339
|
|
|
330
340
|
def test_get_marker_settings_sort_self(self, mock_objects):
|
|
331
|
-
|
|
341
|
+
session, package, module, cls, func = mock_objects
|
|
332
342
|
|
|
333
343
|
order_1 = mock.MagicMock()
|
|
334
344
|
order_1.args = [1]
|
|
@@ -356,7 +366,7 @@ class TestMarkerSettings:
|
|
|
356
366
|
)
|
|
357
367
|
|
|
358
368
|
def test_get_marker_settings_sort_bucket(self, mock_objects):
|
|
359
|
-
|
|
369
|
+
session, package, module, cls, func = mock_objects
|
|
360
370
|
|
|
361
371
|
order_1 = mock.MagicMock()
|
|
362
372
|
order_1.args = [1]
|
|
@@ -377,12 +387,12 @@ class TestMarkerSettings:
|
|
|
377
387
|
assert core.get_marker_settings(func) == ("random", "parent", None, None, 1)
|
|
378
388
|
|
|
379
389
|
def test_get_marker_settings_no_markers(self, mock_objects):
|
|
380
|
-
|
|
390
|
+
session, package, module, cls, func = mock_objects
|
|
381
391
|
|
|
382
392
|
assert core.get_marker_settings(func) == (None, None, None, None, None)
|
|
383
393
|
|
|
384
394
|
def test_get_marker_settings_error(self, mock_objects):
|
|
385
|
-
|
|
395
|
+
session, package, module, cls, func = mock_objects
|
|
386
396
|
|
|
387
397
|
sort_random = mock.MagicMock()
|
|
388
398
|
sort_random.args = ["random", "hello"]
|
|
@@ -410,7 +420,7 @@ class TestCreateSortKey:
|
|
|
410
420
|
def test_marker_bucketid_sortkey(self, get_marker_settings, mock_objects):
|
|
411
421
|
get_marker_settings.return_value = (None, None, "test/core", None, 1234)
|
|
412
422
|
config.SortConfig.bucket_mode = "ordered"
|
|
413
|
-
|
|
423
|
+
session, package, module, cls, func = mock_objects
|
|
414
424
|
|
|
415
425
|
core.create_sort_keys(func, 6, 60)
|
|
416
426
|
|
|
@@ -424,7 +434,7 @@ class TestCreateSortKey:
|
|
|
424
434
|
get_marker_settings.return_value = ("reverse", "class", None, None, None)
|
|
425
435
|
config.SortConfig.mode = "ordered"
|
|
426
436
|
config.SortConfig.bucket_mode = "ordered"
|
|
427
|
-
|
|
437
|
+
session, package, module, cls, func = mock_objects
|
|
428
438
|
|
|
429
439
|
core.create_sort_keys(func, 6, 60)
|
|
430
440
|
|
|
@@ -439,7 +449,7 @@ class TestCreateSortKey:
|
|
|
439
449
|
config.SortConfig.mode = "ordered"
|
|
440
450
|
config.SortConfig.bucket_mode = "ordered"
|
|
441
451
|
config.SortConfig.bucket = "module"
|
|
442
|
-
|
|
452
|
+
session, package, module, cls, func = mock_objects
|
|
443
453
|
|
|
444
454
|
core.create_sort_keys(func, 6, 60)
|
|
445
455
|
|
|
@@ -454,7 +464,7 @@ class TestCreateSortKey:
|
|
|
454
464
|
config.SortConfig.mode = "ordered"
|
|
455
465
|
config.SortConfig.bucket = "module"
|
|
456
466
|
config.SortConfig.bucket_mode = "reverse"
|
|
457
|
-
|
|
467
|
+
session, package, module, cls, func = mock_objects
|
|
458
468
|
|
|
459
469
|
core.create_sort_keys(func, 6, 60)
|
|
460
470
|
|
|
@@ -467,7 +477,7 @@ class TestCreateSortKey:
|
|
|
467
477
|
config.SortConfig.mode = "reverse"
|
|
468
478
|
config.SortConfig.bucket = "module"
|
|
469
479
|
config.SortConfig.bucket_mode = "ordered"
|
|
470
|
-
|
|
480
|
+
session, package, module, cls, func = mock_objects
|
|
471
481
|
|
|
472
482
|
core.create_sort_keys(func, 6, 60)
|
|
473
483
|
|
|
@@ -480,7 +490,7 @@ class TestCreateSortKey:
|
|
|
480
490
|
config.SortConfig.mode = "fastest"
|
|
481
491
|
config.SortConfig.bucket = "class"
|
|
482
492
|
config.SortConfig.bucket_mode = "fastest"
|
|
483
|
-
|
|
493
|
+
session, package, module, cls, func = mock_objects
|
|
484
494
|
|
|
485
495
|
config.SortConfig.item_totals = {
|
|
486
496
|
func.nodeid: 1.1,
|
|
@@ -498,7 +508,7 @@ class TestCreateSortKey:
|
|
|
498
508
|
config.SortConfig.mode = "ordered"
|
|
499
509
|
config.SortConfig.bucket = "module"
|
|
500
510
|
config.SortConfig.bucket_mode = "ordered"
|
|
501
|
-
|
|
511
|
+
session, package, module, cls, func = mock_objects
|
|
502
512
|
|
|
503
513
|
core.create_sort_keys(func, 0, 60)
|
|
504
514
|
core.create_sort_keys(func, 1, 60)
|
|
@@ -512,7 +522,7 @@ class TestCreateSortKey:
|
|
|
512
522
|
config.SortConfig.mode = "ordered"
|
|
513
523
|
config.SortConfig.bucket = "module"
|
|
514
524
|
config.SortConfig.bucket_mode = "md5"
|
|
515
|
-
|
|
525
|
+
session, package, module, cls, func = mock_objects
|
|
516
526
|
|
|
517
527
|
md5.return_value.digest.side_effect = [b"DEF", b"ABC", b"GHI"]
|
|
518
528
|
|
|
@@ -523,7 +533,7 @@ class TestCreateSortKey:
|
|
|
523
533
|
assert config.SortConfig.bucket_sort_keys == {module.nodeid: b"ABC"}
|
|
524
534
|
|
|
525
535
|
def test_get_item_sort_key(self, mock_objects):
|
|
526
|
-
|
|
536
|
+
session, package, module, cls, func = mock_objects
|
|
527
537
|
|
|
528
538
|
core.SortConfig.item_sort_keys = {func.nodeid: 1.1}
|
|
529
539
|
core.SortConfig.item_bucket_id = {func.nodeid: cls.nodeid}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|