diff --git a/macros.python3 b/macros.python3 index c6aa17e..f45af14 100644 --- a/macros.python3 +++ b/macros.python3 @@ -113,4 +113,5 @@ PYTHONPATH="${PYTHONPATH:-%{buildroot}%{python3_sitearch}:%{buildroot}%{python3_sitelib}}"\\\ PYTHONDONTWRITEBYTECODE=1\\\ %{?__pytest_addopts:PYTEST_ADDOPTS="${PYTEST_ADDOPTS:-} %{__pytest_addopts}"}\\\ + PYTEST_XDIST_AUTO_NUM_WORKERS=%{_smp_build_ncpus}\\\ %__pytest} diff --git a/python-rpm-macros.spec b/python-rpm-macros.spec index 8a65425..8c4d3f3 100644 --- a/python-rpm-macros.spec +++ b/python-rpm-macros.spec @@ -52,7 +52,7 @@ elseif posix.stat('macros.python-srpm') then end } Version: %{__default_python3_version} -Release: 5%{?dist} +Release: 6%{?dist} BuildArch: noarch @@ -159,6 +159,10 @@ grep -E '^#[^%%]*%%[^%%]' %{buildroot}%{rpmmacrodir}/macros.* && exit 1 || true %changelog +* Sun Nov 13 2022 Miro Hrončok - 3.11-6 +- Set PYTEST_XDIST_AUTO_NUM_WORKERS=%%{_smp_build_ncpus} from %%pytest +- pytest-xdist 3+ respects this value when -n auto is used + * Tue Oct 25 2022 Lumír Balhar - 3.11-5 - Include pathfix.py in this package diff --git a/tests/test_evals.py b/tests/test_evals.py index 94229dc..183dcc2 100644 --- a/tests/test_evals.py +++ b/tests/test_evals.py @@ -319,6 +319,11 @@ def test_pytest_command_suffix_alternate_pkgversion(version): assert f'/usr/bin/pytest-{version} -v' in lines[-1] +def test_pytest_sets_pytest_xdist_auto_num_workers(): + lines = rpm_eval('%pytest', _smp_build_ncpus=2) + assert 'PYTEST_XDIST_AUTO_NUM_WORKERS=2' in '\n'.join(lines) + + def test_pytest_undefined_addopts_are_not_set(): lines = rpm_eval('%pytest', __pytest_addopts=None) assert 'PYTEST_ADDOPTS' not in '\n'.join(lines)