Skip to content

Commit e21ad3f

Browse files
committed
Allow doctests to be filtered out on circleci
1 parent 4423be1 commit e21ad3f

File tree

3 files changed

+18
-7
lines changed

3 files changed

+18
-7
lines changed

bin/run_tests.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,15 @@
3939
"\n\n================================== DOC TESTS ==================================",
4040
flush=True,
4141
)
42-
subprocess.run(doc_test_args, check=True)
42+
result = subprocess.run(doc_test_args, check=False)
43+
if result.returncode not in (0, 5):
44+
# Allow case where no doctests are collected (returncode 5) because
45+
# circleci sets an explicit "-k" filter that disables doctests. There
46+
# isn't a pattern that will only select doctests. This can be removed
47+
# and have check=True if the circleci PYTEST_ADDOPTS is removed.
48+
raise subprocess.CalledProcessError(
49+
result.returncode, result.args, output=result.stdout,
50+
stderr=result.stderr)
4351

4452
# unit tests
4553
unit_test_args = [sys.executable, "-m", "pytest", "unit_test"]

cibuildwheel/oci_container.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -174,14 +174,17 @@ class OCIContainer:
174174
back to cibuildwheel.
175175
176176
Example:
177+
>>> # xdoctest: +REQUIRES(LINUX)
177178
>>> from cibuildwheel.oci_container import * # NOQA
178179
>>> from cibuildwheel.options import _get_pinned_container_images
179-
>>> image = _get_pinned_container_images()['x86_64']['manylinux2014']
180+
>>> import pytest
180181
>>> try:
181-
>>> oci_platform = OCIPlatform.native()
182-
>>> except OSError as ex:
183-
>>> import pytest
184-
>>> pytest.skip(str(ex))
182+
... oci_platform = OCIPlatform.native()
183+
... except OSError as ex:
184+
... pytest.skip(str(ex))
185+
>>> if oci_platform != OCIPlatform.AMD64:
186+
... pytest.skip('only runs on amd64')
187+
>>> image = _get_pinned_container_images()['x86_64']['manylinux2014']
185188
>>> # Test the default container
186189
>>> with OCIContainer(image=image, oci_platform=oci_platform) as self:
187190
... self.call(["echo", "hello world"])

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ dev = [
104104

105105
[tool.pytest.ini_options]
106106
minversion = "6.0"
107-
addopts = ["-ra", "--showlocals", "--strict-markers", "--strict-config", "--xdoctest"]
107+
addopts = ["-ra", "--showlocals", "--strict-markers", "--strict-config", "--xdoctest", "--ignore-glob=*venv*"]
108108
junit_family = "xunit2"
109109
xfail_strict = true
110110
filterwarnings = ["error"]

0 commit comments

Comments
 (0)