From 381ce789e1662e2e16b0ca4be520cdcf7464f5a3 Mon Sep 17 00:00:00 2001 From: Henry Schreiner Date: Wed, 2 Aug 2023 11:24:44 -0400 Subject: [PATCH] tests: add network marker Signed-off-by: Henry Schreiner --- pyproject.toml | 1 + tests/test_main.py | 30 ++++++++++++++++-------------- tests/test_self_packaging.py | 2 ++ tests/test_util.py | 4 +++- 4 files changed, 22 insertions(+), 15 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index 04575786..accc7e0d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -111,6 +111,7 @@ norecursedirs = "tests/integration/*" markers = [ "isolated", "pypy3323bug", + "network", ] filterwarnings = [ "error", diff --git a/tests/test_main.py b/tests/test_main.py index 515dc22c..e2da2854 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -188,6 +188,7 @@ def test_build_raises_build_backend_exception(mocker, package_test_flit): build.__main__.build_package(package_test_flit, '.', ['sdist']) +@pytest.mark.network @pytest.mark.pypy3323bug def test_build_package(tmp_dir, package_test_setuptools): build.__main__.build_package(package_test_setuptools, tmp_dir, ['sdist', 'wheel']) @@ -198,6 +199,7 @@ def test_build_package(tmp_dir, package_test_setuptools): ] +@pytest.mark.network @pytest.mark.pypy3323bug def test_build_package_via_sdist(tmp_dir, package_test_setuptools): build.__main__.build_package_via_sdist(package_test_setuptools, tmp_dir, ['wheel']) @@ -223,7 +225,7 @@ def test_build_package_via_sdist_invalid_distribution(tmp_dir, package_test_setu @pytest.mark.parametrize( ('args', 'output'), [ - ( + pytest.param( [], [ '* Creating venv isolated environment...', @@ -238,8 +240,10 @@ def test_build_package_via_sdist_invalid_distribution(tmp_dir, package_test_setu '* Building wheel...', 'Successfully built test_setuptools-1.0.0.tar.gz and test_setuptools-1.0.0-py2.py3-none-any.whl', ], + id='via-sdist-isolation', + marks=[pytest.mark.network, pytest.mark.isolated], ), - ( + pytest.param( ['--no-isolation'], [ '* Getting build dependencies for sdist...', @@ -249,8 +253,9 @@ def test_build_package_via_sdist_invalid_distribution(tmp_dir, package_test_setu '* Building wheel...', 'Successfully built test_setuptools-1.0.0.tar.gz and test_setuptools-1.0.0-py2.py3-none-any.whl', ], + id='via-sdist-no-isolation', ), - ( + pytest.param( ['--wheel'], [ '* Creating venv isolated environment...', @@ -260,24 +265,28 @@ def test_build_package_via_sdist_invalid_distribution(tmp_dir, package_test_setu '* Building wheel...', 'Successfully built test_setuptools-1.0.0-py2.py3-none-any.whl', ], + id='wheel-direct-isolation', + marks=[pytest.mark.network, pytest.mark.isolated], ), - ( + pytest.param( ['--wheel', '--no-isolation'], [ '* Getting build dependencies for wheel...', '* Building wheel...', 'Successfully built test_setuptools-1.0.0-py2.py3-none-any.whl', ], + id='wheel-direct-no-isolation', ), - ( + pytest.param( ['--sdist', '--no-isolation'], [ '* Getting build dependencies for sdist...', '* Building sdist...', 'Successfully built test_setuptools-1.0.0.tar.gz', ], + id='sdist-direct-no-isolation', ), - ( + pytest.param( ['--sdist', '--wheel', '--no-isolation'], [ '* Getting build dependencies for sdist...', @@ -286,16 +295,9 @@ def test_build_package_via_sdist_invalid_distribution(tmp_dir, package_test_setu '* Building wheel...', 'Successfully built test_setuptools-1.0.0.tar.gz and test_setuptools-1.0.0-py2.py3-none-any.whl', ], + id='sdist-and-wheel-direct-no-isolation', ), ], - ids=[ - 'via-sdist-isolation', - 'via-sdist-no-isolation', - 'wheel-direct-isolation', - 'wheel-direct-no-isolation', - 'sdist-direct-no-isolation', - 'sdist-and-wheel-direct-no-isolation', - ], ) @pytest.mark.flaky(reruns=5) def test_output(package_test_setuptools, tmp_dir, capsys, args, output): diff --git a/tests/test_self_packaging.py b/tests/test_self_packaging.py index b134f53c..f369bbb0 100644 --- a/tests/test_self_packaging.py +++ b/tests/test_self_packaging.py @@ -45,6 +45,7 @@ } +@pytest.mark.network def test_build_sdist(monkeypatch, tmpdir): monkeypatch.chdir(MAIN_DIR) @@ -68,6 +69,7 @@ def test_build_sdist(monkeypatch, tmpdir): assert simpler == sdist_files +@pytest.mark.network @pytest.mark.parametrize('args', ((), ('--wheel',)), ids=('from_sdist', 'direct')) def test_build_wheel(monkeypatch, tmpdir, args): monkeypatch.chdir(MAIN_DIR) diff --git a/tests/test_util.py b/tests/test_util.py index 3be20df6..74f2cf1e 100644 --- a/tests/test_util.py +++ b/tests/test_util.py @@ -8,7 +8,7 @@ @pytest.mark.pypy3323bug -@pytest.mark.parametrize('isolated', [False, True]) +@pytest.mark.parametrize('isolated', [False, pytest.param(True, marks=[pytest.mark.network, pytest.mark.isolated])]) def test_wheel_metadata(package_test_setuptools, isolated): metadata = build.util.project_wheel_metadata(package_test_setuptools, isolated) @@ -16,6 +16,7 @@ def test_wheel_metadata(package_test_setuptools, isolated): assert metadata['version'] == '1.0.0' +@pytest.mark.network @pytest.mark.pypy3323bug def test_wheel_metadata_isolation(package_test_flit): if importlib.util.find_spec('flit_core'): @@ -33,6 +34,7 @@ def test_wheel_metadata_isolation(package_test_flit): build.util.project_wheel_metadata(package_test_flit, isolated=False) +@pytest.mark.network @pytest.mark.pypy3323bug def test_with_get_requires(package_test_metadata): metadata = build.util.project_wheel_metadata(package_test_metadata)