From 8395e5291a65b87b7dea425db4d0a5afef22cf46 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Fri, 7 Mar 2025 17:32:42 -0500 Subject: [PATCH 1/4] tests: better support for parallel testing Signed-off-by: Henry Schreiner --- tests/conftest.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index 812e2261..117e8627 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -103,8 +103,14 @@ def packages_path(): def generate_package_path_fixture(package_name): @pytest.fixture - def fixture(packages_path): - return os.path.join(packages_path, package_name) + def fixture(packages_path, tmp_path): + package_path = os.path.join(packages_path, package_name) + if 'flit' in package_name: + return package_path + + new_path = tmp_path / package_name + shutil.copytree(package_path, new_path) + return str(new_path) return fixture From 1c46f205b4ce8fdd746ab1362156bd3227f2f07c Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Sat, 8 Mar 2025 12:04:58 -0500 Subject: [PATCH 2/4] tests: only copy setuptools Signed-off-by: Henry Schreiner --- tests/conftest.py | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index 117e8627..49d5dcce 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -12,11 +12,17 @@ import tempfile from functools import partial, update_wrapper +from pathlib import Path import pytest import build.env +if sys.version_info < (3, 11): + import tomli as tomllib +else: + import tomllib + def pytest_addoption(parser): os.environ['PYTHONWARNINGS'] = 'ignore:DEPRECATION::pip._internal.cli.base_command' # for when not run within tox @@ -101,12 +107,25 @@ def packages_path(): return os.path.realpath(os.path.join(__file__, '..', 'packages')) +def is_setuptools(package_path): + if package_path.joinpath("setup.py").is_file(): + return True + pyproject = package_path / "pyproject.toml" + try: + with pyproject.open("rb") as f: + pp = tomllib.load(f) + except (FileNotFoundError, ValueError): + return True + return "setuptools" in pp.get("build-system", {}).get("build-backend", "setuptools") + + + def generate_package_path_fixture(package_name): @pytest.fixture def fixture(packages_path, tmp_path): - package_path = os.path.join(packages_path, package_name) - if 'flit' in package_name: - return package_path + package_path = Path(packages_path) / package_name + if not is_setuptools(package_path): + return str(package_path) new_path = tmp_path / package_name shutil.copytree(package_path, new_path) From de9567a5ed95f87c68f2f1a3a6af68739cdc7f5f Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Sat, 8 Mar 2025 20:42:40 -0500 Subject: [PATCH 3/4] Update tests/conftest.py Co-authored-by: layday --- tests/conftest.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index 49d5dcce..0703b7d0 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -18,10 +18,7 @@ import build.env -if sys.version_info < (3, 11): - import tomli as tomllib -else: - import tomllib +from build._compat import tomllib def pytest_addoption(parser): From 2be2a2dbd59dae9a774623d264b99cfc2829ba0e Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sun, 9 Mar 2025 08:10:56 +0000 Subject: [PATCH 4/4] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/conftest.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/tests/conftest.py b/tests/conftest.py index 0703b7d0..6923a5f4 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -105,16 +105,15 @@ def packages_path(): def is_setuptools(package_path): - if package_path.joinpath("setup.py").is_file(): + if package_path.joinpath('setup.py').is_file(): return True - pyproject = package_path / "pyproject.toml" + pyproject = package_path / 'pyproject.toml' try: - with pyproject.open("rb") as f: + with pyproject.open('rb') as f: pp = tomllib.load(f) except (FileNotFoundError, ValueError): return True - return "setuptools" in pp.get("build-system", {}).get("build-backend", "setuptools") - + return 'setuptools' in pp.get('build-system', {}).get('build-backend', 'setuptools') def generate_package_path_fixture(package_name):