Skip to content

Commit 827909b

Browse files
authored
Merge pull request #723 from bluetech/modernize
Modernize packaging, require pytest 6.2, prepare for pytest 7, other changes
2 parents b2f3d08 + ae58690 commit 827909b

21 files changed

+898
-761
lines changed

.pre-commit-config.yaml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ repos:
44
hooks:
55
- id: black
66
args: [--safe, --quiet, --target-version, py35]
7-
language_version: python3.7
87
- repo: https://github.com/pre-commit/pre-commit-hooks
98
rev: v4.0.1
109
hooks:
@@ -29,4 +28,12 @@ repos:
2928
files: ^(CHANGELOG.rst|HOWTORELEASE.rst|README.rst|changelog/.*)$
3029
language: python
3130
additional_dependencies: [pygments, restructuredtext_lint]
32-
language_version: python3.7
31+
- repo: https://github.com/pre-commit/mirrors-mypy
32+
rev: v0.910-1
33+
hooks:
34+
- id: mypy
35+
files: ^(src/|testing/)
36+
args: []
37+
additional_dependencies:
38+
- pytest>=6.2.0
39+
- py>=1.10.0

changelog/719.trivial.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Use up-to-date ``setup.cfg``/``pyproject.toml`` packaging setup.

changelog/720.trivial.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Require pytest>=6.2.0.

changelog/721.trivial.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Started using type annotations and mypy checking internally. The types are incomplete and not published.

changelog/722.feature.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Full compatibility with pytest 7 - no deprecation warnings or use of legacy features.

pyproject.toml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
[build-system]
2+
requires = [
3+
# sync with setup.py until we discard non-pep-517/518
4+
"setuptools>=45.0",
5+
"setuptools-scm[toml]>=6.2.3",
6+
"wheel",
7+
]
8+
build-backend = "setuptools.build_meta"
9+
10+
[tool.setuptools_scm]
11+
write_to = "src/xdist/_version.py"
12+
113
[tool.towncrier]
214
package = "xdist"
315
filename = "CHANGELOG.rst"

setup.cfg

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,76 @@
11
[metadata]
2+
name = pytest-xdist
3+
description = pytest xdist plugin for distributed testing and loop-on-failing modes
4+
long_description = file: README.rst
5+
license = MIT
6+
author = holger krekel and contributors
7+
8+
url = https://github.com/pytest-dev/pytest-xdist
9+
platforms =
10+
linux
11+
osx
12+
win32
13+
classifiers =
14+
Development Status :: 5 - Production/Stable
15+
Framework :: Pytest
16+
Intended Audience :: Developers
17+
License :: OSI Approved :: MIT License
18+
Operating System :: POSIX
19+
Operating System :: Microsoft :: Windows
20+
Operating System :: MacOS :: MacOS X
21+
Topic :: Software Development :: Testing
22+
Topic :: Software Development :: Quality Assurance
23+
Topic :: Utilities
24+
Programming Language :: Python
25+
Programming Language :: Python :: 3
26+
Programming Language :: Python :: 3 :: Only
27+
Programming Language :: Python :: 3.6
28+
Programming Language :: Python :: 3.7
29+
Programming Language :: Python :: 3.8
30+
Programming Language :: Python :: 3.9
31+
Programming Language :: Python :: 3.10
232
license_file = LICENSE
333

34+
[options]
35+
packages = find:
36+
package_dir = =src
37+
zip_safe = False
38+
python_requires = >=3.6
39+
install_requires =
40+
execnet>=1.1
41+
pytest>=6.2.0
42+
pytest-forked
43+
setup_requires = setuptools_scm>=6.0
44+
45+
[options.packages.find]
46+
where = src
47+
48+
[options.entry_points]
49+
pytest11 =
50+
xdist = xdist.plugin
51+
xdist.looponfail = xdist.looponfail
52+
53+
[options.extras_require]
54+
testing =
55+
filelock
56+
psutil = psutil>=3.0
57+
setproctitle = setproctitle
58+
459
[flake8]
560
max-line-length = 100
61+
62+
[mypy]
63+
mypy_path = src
64+
# TODO: Enable this & fix errors.
65+
# check_untyped_defs = True
66+
disallow_any_generics = True
67+
ignore_missing_imports = True
68+
no_implicit_optional = True
69+
show_error_codes = True
70+
strict_equality = True
71+
warn_redundant_casts = True
72+
warn_return_any = True
73+
warn_unreachable = True
74+
warn_unused_configs = True
75+
# TODO: Enable this & fix errors.
76+
# no_implicit_reexport = True

setup.py

Lines changed: 3 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,4 @@
1-
from setuptools import setup, find_packages
1+
from setuptools import setup
22

3-
install_requires = ["execnet>=1.1", "pytest>=6.0.0", "pytest-forked"]
4-
5-
6-
with open("README.rst") as f:
7-
long_description = f.read()
8-
9-
setup(
10-
name="pytest-xdist",
11-
use_scm_version={"write_to": "src/xdist/_version.py"},
12-
description="pytest xdist plugin for distributed testing and loop-on-failing modes",
13-
long_description=long_description,
14-
license="MIT",
15-
author="holger krekel and contributors",
16-
17-
url="https://github.com/pytest-dev/pytest-xdist",
18-
platforms=["linux", "osx", "win32"],
19-
packages=find_packages(where="src"),
20-
package_dir={"": "src"},
21-
extras_require={
22-
"testing": ["filelock"],
23-
"psutil": ["psutil>=3.0"],
24-
"setproctitle": ["setproctitle"],
25-
},
26-
entry_points={
27-
"pytest11": ["xdist = xdist.plugin", "xdist.looponfail = xdist.looponfail"]
28-
},
29-
zip_safe=False,
30-
python_requires=">=3.6",
31-
install_requires=install_requires,
32-
setup_requires=["setuptools_scm"],
33-
classifiers=[
34-
"Development Status :: 5 - Production/Stable",
35-
"Framework :: Pytest",
36-
"Intended Audience :: Developers",
37-
"License :: OSI Approved :: MIT License",
38-
"Operating System :: POSIX",
39-
"Operating System :: Microsoft :: Windows",
40-
"Operating System :: MacOS :: MacOS X",
41-
"Topic :: Software Development :: Testing",
42-
"Topic :: Software Development :: Quality Assurance",
43-
"Topic :: Utilities",
44-
"Programming Language :: Python",
45-
"Programming Language :: Python :: 3",
46-
"Programming Language :: Python :: 3 :: Only",
47-
"Programming Language :: Python :: 3.6",
48-
"Programming Language :: Python :: 3.7",
49-
"Programming Language :: Python :: 3.8",
50-
"Programming Language :: Python :: 3.9",
51-
"Programming Language :: Python :: 3.10",
52-
],
53-
)
3+
if __name__ == "__main__":
4+
setup()

src/xdist/looponfail.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def pytest_cmdline_main(config):
3838

3939
def looponfail_main(config):
4040
remotecontrol = RemoteControl(config)
41-
rootdirs = config.getini("looponfailroots")
41+
rootdirs = [py.path.local(root) for root in config.getini("looponfailroots")]
4242
statrecorder = StatRecorder(rootdirs)
4343
try:
4444
while 1:

src/xdist/plugin.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
import os
22
import uuid
33
import sys
4+
from pathlib import Path
45

56
import py
67
import pytest
78

9+
10+
PYTEST_GTE_7 = hasattr(pytest, "version_tuple") and pytest.version_tuple >= (7, 0) # type: ignore[attr-defined]
11+
812
_sys_path = list(sys.path) # freeze a copy of sys.path at interpreter startup
913

1014

@@ -147,18 +151,18 @@ def pytest_addoption(parser):
147151
parser.addini(
148152
"rsyncdirs",
149153
"list of (relative) paths to be rsynced for remote distributed testing.",
150-
type="pathlist",
154+
type="paths" if PYTEST_GTE_7 else "pathlist",
151155
)
152156
parser.addini(
153157
"rsyncignore",
154158
"list of (relative) glob-style paths to be ignored for rsyncing.",
155-
type="pathlist",
159+
type="paths" if PYTEST_GTE_7 else "pathlist",
156160
)
157161
parser.addini(
158162
"looponfailroots",
159-
type="pathlist",
163+
type="paths" if PYTEST_GTE_7 else "pathlist",
160164
help="directories to check for changes",
161-
default=[py.path.local()],
165+
default=[Path.cwd() if PYTEST_GTE_7 else py.path.local()],
162166
)
163167

164168

@@ -250,7 +254,7 @@ def is_xdist_controller(request_or_session) -> bool:
250254
is_xdist_master = is_xdist_controller
251255

252256

253-
def get_xdist_worker_id(request_or_session) -> str:
257+
def get_xdist_worker_id(request_or_session):
254258
"""Return the id of the current worker ('gw0', 'gw1', etc) or 'master'
255259
if running on the controller node.
256260

0 commit comments

Comments
 (0)