pytest-sort 1.3.1__tar.gz → 1.3.2__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.
Files changed (22) hide show
  1. {pytest-sort-1.3.1/src/pytest_sort.egg-info → pytest_sort-1.3.2}/PKG-INFO +3 -2
  2. {pytest-sort-1.3.1 → pytest_sort-1.3.2}/pyproject.toml +20 -16
  3. {pytest-sort-1.3.1 → pytest_sort-1.3.2}/src/pytest_sort/core.py +2 -5
  4. {pytest-sort-1.3.1 → pytest_sort-1.3.2}/src/pytest_sort/database.py +4 -16
  5. {pytest-sort-1.3.1 → pytest_sort-1.3.2}/src/pytest_sort/diffcov.py +6 -3
  6. {pytest-sort-1.3.1 → pytest_sort-1.3.2}/src/pytest_sort/plugin.py +3 -1
  7. {pytest-sort-1.3.1 → pytest_sort-1.3.2/src/pytest_sort.egg-info}/PKG-INFO +3 -2
  8. {pytest-sort-1.3.1 → pytest_sort-1.3.2}/test/test_core.py +4 -18
  9. {pytest-sort-1.3.1 → pytest_sort-1.3.2}/LICENSE +0 -0
  10. {pytest-sort-1.3.1 → pytest_sort-1.3.2}/README.md +0 -0
  11. {pytest-sort-1.3.1 → pytest_sort-1.3.2}/setup.cfg +0 -0
  12. {pytest-sort-1.3.1 → pytest_sort-1.3.2}/src/pytest_sort/__init__.py +0 -0
  13. {pytest-sort-1.3.1 → pytest_sort-1.3.2}/src/pytest_sort/config.py +0 -0
  14. {pytest-sort-1.3.1 → pytest_sort-1.3.2}/src/pytest_sort.egg-info/SOURCES.txt +0 -0
  15. {pytest-sort-1.3.1 → pytest_sort-1.3.2}/src/pytest_sort.egg-info/dependency_links.txt +0 -0
  16. {pytest-sort-1.3.1 → pytest_sort-1.3.2}/src/pytest_sort.egg-info/entry_points.txt +0 -0
  17. {pytest-sort-1.3.1 → pytest_sort-1.3.2}/src/pytest_sort.egg-info/requires.txt +0 -0
  18. {pytest-sort-1.3.1 → pytest_sort-1.3.2}/src/pytest_sort.egg-info/top_level.txt +0 -0
  19. {pytest-sort-1.3.1 → pytest_sort-1.3.2}/test/test_config.py +0 -0
  20. {pytest-sort-1.3.1 → pytest_sort-1.3.2}/test/test_database.py +0 -0
  21. {pytest-sort-1.3.1 → pytest_sort-1.3.2}/test/test_diffcov.py +0 -0
  22. {pytest-sort-1.3.1 → pytest_sort-1.3.2}/test/test_plugin.py +0 -0
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: pytest-sort
3
- Version: 1.3.1
3
+ Version: 1.3.2
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>
@@ -40,6 +40,7 @@ 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
+ Dynamic: license-file
43
44
 
44
45
  [![Homepage](https://img.shields.io/badge/Homepage-github-white?logo=github)](https://github.com/WiredNerd/pytest-sort)
45
46
  [![python>=3.8](https://img.shields.io/badge/python->=3.8-orange?logo=python&logoColor=green)](https://pypi.org/project/pytest-sort)
@@ -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.1"
8
+ version = "1.3.2"
9
9
  license = { file = "LICENSE" }
10
10
  keywords = [
11
11
  "test",
@@ -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 = ['py38', 'py39', 'py310', 'py311']
67
+ target-version = ['py39', 'py310', 'py311', 'py312', 'py313']
68
68
  skip-string-normalization = true
69
69
  color = true
70
70
 
@@ -76,19 +76,8 @@ files = "src"
76
76
  mypy_path = "src"
77
77
 
78
78
  [tool.ruff]
79
- target-version = "py38"
80
- show-source = true
81
- select = ["ALL"]
82
- ignore = [
83
- "ANN101", # Missing type annotation for self in method
84
- "COM812", # missing-trailing-comma
85
- "D203", # 1 blank line required before class docstring
86
- "D213", # multi-line-summary-second-line
87
- "EM101", # Exception must not use a string literal, assign to variable first
88
- "ISC001", # single-line-implicit-string-concatenation
89
- "S311", # Standard pseudo-random generators are not suitable for cryptographic purposes
90
- "TRY003", # Avoid specifying long messages outside the exception class
91
- ]
79
+ target-version = "py39"
80
+ output-format = "full"
92
81
  line-length = 120
93
82
  exclude = [
94
83
  ".eggs",
@@ -104,10 +93,25 @@ exclude = [
104
93
  "venv",
105
94
  ]
106
95
 
96
+ [tool.ruff.lint]
97
+ select = ["ALL"]
98
+ ignore = [
99
+ "COM812", # missing-trailing-comma
100
+ "D203", # 1 blank line required before class docstring
101
+ "D213", # multi-line-summary-second-line
102
+ "EM101", # Exception must not use a string literal, assign to variable first
103
+ "ISC001", # single-line-implicit-string-concatenation
104
+ "S311", # Standard pseudo-random generators are not suitable for cryptographic purposes
105
+ "TRY003", # Avoid specifying long messages outside the exception class
106
+ ]
107
+
108
+ [tool.ruff.lint.flake8-pytest-style]
109
+ fixture-parentheses = true
110
+
107
111
  [tool.ruff.lint.isort]
108
112
  known-first-party = ["pytest_sort"]
109
113
 
110
- [tool.ruff.per-file-ignores]
114
+ [tool.ruff.lint.per-file-ignores]
111
115
  "src/pytest_sort/core.py" = [
112
116
  "ARG005", # Unused lambda argument
113
117
  "T201", # print found
@@ -4,7 +4,6 @@ from __future__ import annotations
4
4
 
5
5
  import hashlib
6
6
  import random
7
- import sys
8
7
  from functools import partial
9
8
  from typing import TYPE_CHECKING, Any, Callable
10
9
 
@@ -15,9 +14,7 @@ from pytest_sort.config import SortConfig
15
14
  from pytest_sort.database import get_all_totals, get_stats
16
15
  from pytest_sort.diffcov import get_diff_test_scores, get_mut_test_scores
17
16
 
18
- md5: Callable = hashlib.md5
19
- if sys.version_info >= (3, 9):
20
- md5: Callable = partial(hashlib.md5, usedforsecurity=False) # type: ignore[no-redef]
17
+ md5: Callable = partial(hashlib.md5, usedforsecurity=False) # type: ignore[no-redef]
21
18
 
22
19
 
23
20
  if TYPE_CHECKING:
@@ -254,7 +251,7 @@ def print_recorded_times_report(terminal_reporter: TerminalReporter) -> None:
254
251
 
255
252
  print(
256
253
  f"\n*** {'pytest-sort maximum recorded times'.ljust(node_id_width)}"
257
- f"{'Nanoseconds'.center(stat_width*4 - 4)} ***",
254
+ f"{'Nanoseconds'.center(stat_width * 4 - 4)} ***",
258
255
  )
259
256
  print(
260
257
  f"{'Test Case'.ljust(node_id_width)} {'setup'.rjust(stat_width)} "
@@ -31,24 +31,12 @@ def update_test_cases(recorded_times: dict) -> None:
31
31
  """Update Test Case Data with specfiied duration(s) and recalculate total(s)."""
32
32
  _load_data()
33
33
 
34
- for nodeid in recorded_times:
34
+ for nodeid, recorded_node in recorded_times.items():
35
35
  node_data = _sort_data.get(nodeid, {})
36
36
 
37
- node_data["setup"] = node_data.get("setup", 0)
38
- node_data["call"] = node_data.get("call", 0)
39
- node_data["teardown"] = node_data.get("teardown", 0)
40
-
41
- setup = recorded_times[nodeid].get("setup", 0)
42
- if node_data["setup"] < setup:
43
- node_data["setup"] = setup
44
-
45
- call = recorded_times[nodeid].get("call", 0)
46
- if node_data["call"] < call:
47
- node_data["call"] = call
48
-
49
- teardown = recorded_times[nodeid].get("teardown", 0)
50
- if node_data["teardown"] < teardown:
51
- node_data["teardown"] = teardown
37
+ node_data["setup"] = max(node_data.get("setup", 0), recorded_node.get("setup", 0))
38
+ node_data["call"] = max(node_data.get("call", 0), recorded_node.get("call", 0))
39
+ node_data["teardown"] = max(node_data.get("teardown", 0), recorded_node.get("teardown", 0))
52
40
 
53
41
  node_data["total"] = node_data["setup"] + node_data["call"] + node_data["teardown"]
54
42
 
@@ -7,11 +7,14 @@ import re
7
7
  import shlex
8
8
  import subprocess
9
9
  from pathlib import Path
10
- from typing import Any, Generator
10
+ from typing import TYPE_CHECKING, Any
11
11
 
12
12
  import whatthepatch
13
13
  from coverage.sqldata import CoverageData
14
14
 
15
+ if TYPE_CHECKING:
16
+ from collections.abc import Generator
17
+
15
18
  # pytest-cov populates test context as <nodeid>|(setup|run|teardown)
16
19
  PARSE_TEST_CONTEXT = re.compile(r"(?P<nodeid>.*)\|(?P<when>setup|run|teardown)")
17
20
 
@@ -50,10 +53,10 @@ def get_mut_changed_lines() -> dict[Path, set[int]]:
50
53
  """
51
54
  changed_lines = {}
52
55
  mut_source_file = os.environ.get("MUT_SOURCE_FILE", None)
53
- mut_lineno = os.environ.get("MUT_LINENO", 0)
56
+ mut_lineno = os.environ.get("MUT_LINENO", "0")
54
57
  mut_end_lineno = os.environ.get("MUT_END_LINENO", mut_lineno)
55
58
 
56
- if mut_source_file and mut_lineno:
59
+ if mut_source_file and int(mut_lineno):
57
60
  rpath = Path(mut_source_file).resolve()
58
61
  changed_lines[rpath] = set(range(int(mut_lineno), int(mut_end_lineno) + 1))
59
62
 
@@ -3,7 +3,7 @@
3
3
  from __future__ import annotations
4
4
 
5
5
  import argparse
6
- from typing import TYPE_CHECKING, Generator
6
+ from typing import TYPE_CHECKING
7
7
 
8
8
  import pytest
9
9
 
@@ -12,6 +12,8 @@ from pytest_sort.core import print_recorded_times_report, sort_items
12
12
  from pytest_sort.database import clear_db, update_test_cases
13
13
 
14
14
  if TYPE_CHECKING:
15
+ from collections.abc import Generator
16
+
15
17
  from _pytest.terminal import TerminalReporter
16
18
 
17
19
 
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.4
2
2
  Name: pytest-sort
3
- Version: 1.3.1
3
+ Version: 1.3.2
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>
@@ -40,6 +40,7 @@ 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
+ Dynamic: license-file
43
44
 
44
45
  [![Homepage](https://img.shields.io/badge/Homepage-github-white?logo=github)](https://github.com/WiredNerd/pytest-sort)
45
46
  [![python>=3.8](https://img.shields.io/badge/python->=3.8-orange?logo=python&logoColor=green)](https://pypi.org/project/pytest-sort)
@@ -1,6 +1,5 @@
1
1
  import hashlib
2
2
  import importlib
3
- import sys
4
3
  from functools import partial
5
4
  from typing import Callable, ClassVar
6
5
  from unittest import mock
@@ -10,9 +9,7 @@ from _pytest import nodes as pytest_nodes
10
9
 
11
10
  from pytest_sort import config, core
12
11
 
13
- md5: Callable = hashlib.md5
14
- if sys.version_info >= (3, 9):
15
- md5: Callable = partial(hashlib.md5, usedforsecurity=False) # type: ignore[no-redef]
12
+ md5: Callable = partial(hashlib.md5, usedforsecurity=False) # type: ignore[no-redef]
16
13
 
17
14
 
18
15
  class TestImports:
@@ -21,23 +18,12 @@ class TestImports:
21
18
  with mock.patch("hashlib.md5") as mock_md5:
22
19
  yield mock_md5
23
20
 
24
- @pytest.fixture()
25
- def version_info(self):
26
- with mock.patch("sys.version_info") as version_info:
27
- yield version_info
28
-
29
21
  @pytest.fixture(autouse=True)
30
22
  def _cleanup(self):
31
23
  yield
32
24
  importlib.reload(core)
33
25
 
34
- def test_import_md5_38(self, version_info, mock_md5):
35
- version_info.__ge__ = lambda _, __: False
36
- importlib.reload(core)
37
- assert core.md5 == mock_md5
38
-
39
- def test_import_md5_39(self, version_info, mock_md5):
40
- version_info.__ge__ = lambda _, v: v == (3, 9)
26
+ def test_import_md5_39(self, mock_md5):
41
27
  importlib.reload(core)
42
28
  assert isinstance(core.md5, partial)
43
29
  assert core.md5.func == mock_md5
@@ -235,7 +221,7 @@ class TestValidateMarker:
235
221
  with pytest.raises(TypeError, match="^Incorrect arguments on marker 'order'. Target:testnodeid$") as type_error:
236
222
  core.validate_order_marker(order_marker, "testnodeid")
237
223
 
238
- assert type(type_error.value.__cause__) == TypeError
224
+ assert isinstance(type_error.value.__cause__, TypeError)
239
225
 
240
226
  @pytest.mark.parametrize(
241
227
  ("args", "kwargs", "key"),
@@ -261,7 +247,7 @@ class TestValidateMarker:
261
247
  with pytest.raises(TypeError, match="^Incorrect arguments on marker 'sort'. Target:testnodeid$") as type_error:
262
248
  core.validate_sort_marker(sort_marker, "testnodeid")
263
249
 
264
- assert type(type_error.value.__cause__) == TypeError
250
+ assert isinstance(type_error.value.__cause__, TypeError)
265
251
 
266
252
  def test_validate_sort_marker_value_error(self):
267
253
  sort_marker = mock.MagicMock()
File without changes
File without changes
File without changes