Repository: scikit-build/scikit-build-core
Pull request #379 (2023-06-14 19:30:11)

tests: add network marker
Adding a proper network marker. Tested locally by turning off my wifi. :)

See #368.



Patch:
diff --git a/docs/examples/getting_started/swig/CMakeLists.txt b/docs/examples/getting_started/swig/CMakeLists.txt
index 2caf3df..e0c3b34 100644
--- a/docs/examples/getting_started/swig/CMakeLists.txt
+++ b/docs/examples/getting_started/swig/CMakeLists.txt
@@ -11,14 +11,18 @@ find_package(
   COMPONENTS python
   REQUIRED)
 
-add_custom_command(
-  OUTPUT example.py example_wrap.c
-  COMMAND ${SWIG_EXECUTABLE} -python -outcurrentdir
-          "${CMAKE_CURRENT_SOURCE_DIR}/example.i"
-  DEPENDS example.i)
+include(UseSWIG)
 
-python_add_library(_example MODULE example.c
-                   "${CMAKE_CURRENT_BINARY_DIR}/example_wrap.c" WITH_SOABI)
+swig_add_library(
+  example
+  LANGUAGE python OUTPUT_DIR "${SKBUILD_PLATLIB_DIR}"
+  SOURCES example.i example.c)
+if(WIN32)
+  set_property(TARGET example PROPERTY SUFFIX ".${Python_SOABI}.pyd")
+else()
+  set_property(TARGET example
+               PROPERTY SUFFIX ".${Python_SOABI}${CMAKE_SHARED_MODULE_SUFFIX}")
+endif()
+target_link_libraries(example PRIVATE Python::Module)
 
-install(TARGETS _example DESTINATION .)
-install(FILES "${CMAKE_CURRENT_BINARY_DIR}/example.py" DESTINATION .)
+install(TARGETS example DESTINATION .)
diff --git a/pyproject.toml b/pyproject.toml
index e6cc523..4236a4a 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -119,6 +119,7 @@ markers = [
     "fortran: Fortran code",
     "integration: Full package build",
     "isolated: Needs an isolated virtualenv",
+    "network: Needs a network connection to setup or run",
     "setuptools: Tests setuptools integration",
     "virtualenv: Needs a virtualenv",
 ]


Test patch:
diff --git a/tests/conftest.py b/tests/conftest.py
index 48d7852..0fd0855 100644
--- a/tests/conftest.py
+++ b/tests/conftest.py
@@ -297,6 +297,7 @@ def pytest_collection_modifyitems(items: list[pytest.Item]) -> None:
         if "isolated" in getattr(item, "fixturenames", ()):
             item.add_marker(pytest.mark.virtualenv)
             item.add_marker(pytest.mark.isolated)
+            item.add_marker(pytest.mark.network)
 
 
 def pytest_report_header() -> str:
diff --git a/tests/test_fortran.py b/tests/test_fortran.py
index aee8882..598b0ce 100644
--- a/tests/test_fortran.py
+++ b/tests/test_fortran.py
@@ -27,6 +27,7 @@ ninja_info = best_program(get_ninja_programs(), minimum_version=Version("1.10"))
 @pytest.mark.compile()
 @pytest.mark.configure()
 @pytest.mark.fortran()
+@pytest.mark.network()
 @pytest.mark.skipif(shutil.which("gfortran") is None, reason="gfortran not available")
 @pytest.mark.skipif(
     sysconfig.get_platform().startswith("win"),
diff --git a/tests/test_pyproject_pep518.py b/tests/test_pyproject_pep518.py
index a3a4a53..a46a98c 100644
--- a/tests/test_pyproject_pep518.py
+++ b/tests/test_pyproject_pep518.py
@@ -10,7 +10,7 @@ from pathlib import Path
 import pytest
 
 
-@pytest.mark.isolated()
+@pytest.mark.network()
 @pytest.mark.integration()
 def test_pep518_sdist(package_simple_pyproject_ext):
     correct_metadata = textwrap.dedent(