Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make the test suite connectivity-agnostic. #12095

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
782812e
tests: network: serve remote images from local test HTTP servers
jayaddison Mar 14, 2024
2339a93
epub: offline test fixup: remove non-local image from root test project
jayaddison Mar 14, 2024
514ad2e
Merge branch 'master' into issue-12094/test-suite-connectivity-agnostic
jayaddison Apr 9, 2024
fb23eff
Tests: test_latex_images: match against test HTTP server address.
jayaddison Apr 9, 2024
f6e6c0e
Revert "Tests: test_latex_images: match against test HTTP server addr…
jayaddison Apr 9, 2024
92516f8
Tests: test_latex_images: use a static test HTTP server port number.
jayaddison Apr 9, 2024
9ca2670
Remote image post-transform: add a character-translation for port num…
jayaddison Apr 9, 2024
a7f306d
Merge branch 'issue-12100/image-url-to-directory-safechars' into issu…
jayaddison Apr 9, 2024
ebc6d1a
Tests: cleanup: remove the if_online and sphinx_remote_query_address …
jayaddison Apr 9, 2024
2721a9f
Tests: cleanup: remove no-longer-used _HOST_ONLINE_ERROR key and _que…
jayaddison Apr 9, 2024
8d6c7dc
Tests: cleanup: remove unused import.
jayaddison Apr 9, 2024
c1ca06a
Revert "Remote image post-transform: add a character-translation for …
jayaddison Apr 10, 2024
04d7c9d
Tests: test_latex_images: mark as xfail for non-posix, pending #12100…
jayaddison Apr 10, 2024
828359d
Remote image post-transform: retain on-disk path on posix systems.
jayaddison Apr 10, 2024
fdd724b
Codestyle: reformat image-download URI-to-fs-path translations.
jayaddison Apr 10, 2024
c2bd5e2
Merge branch 'issue-12100/image-url-to-directory-safechars' into issu…
jayaddison Apr 10, 2024
7654fb0
Revert "Tests: test_latex_images: mark as xfail for non-posix, pendin…
jayaddison Apr 10, 2024
2a66eee
Merge branch 'master' into issue-12094/test-suite-connectivity-agnostic
jayaddison Apr 12, 2024
e65432c
Merge branch 'refs/heads/master' into issue-12094/test-suite-connecti…
AA-Turner Apr 12, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Tests: cleanup: remove the if_online and sphinx_remote_query_address …
…fixtures.
  • Loading branch information
jayaddison committed Apr 9, 2024
commit ebc6d1a96dabe07aa0c9d59b6903baa8e161bd15
30 changes: 0 additions & 30 deletions sphinx/testing/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,36 +252,6 @@ def _query(address: tuple[str, int]) -> str | None:
return None


@pytest.fixture(scope='session')
def sphinx_remote_query_address() -> tuple[str, int]:
"""Address to which a query is made to check that the host is online.

By default, onlineness is tested by querying the DNS server ``1.1.1.1``
but users concerned about privacy might change it in ``conftest.py``.
"""
return ('1.1.1.1', 80)


@pytest.fixture(scope='session')
def if_online( # NoQA: PT004
request: pytest.FixtureRequest,
sphinx_remote_query_address: tuple[str, int],
) -> None:
"""Skip the test if the host has no connection.

Usage::

@pytest.mark.usefixtures('if_online')
def test_if_host_is_online(): ...
"""
if _HOST_ONLINE_ERROR not in request.session.stash:
# do not use setdefault() to avoid creating a socket connection
lookup_error = _query(sphinx_remote_query_address)
request.session.stash[_HOST_ONLINE_ERROR] = lookup_error
if (error := request.session.stash[_HOST_ONLINE_ERROR]) is not None:
pytest.skip('host appears to be offline (%s)' % error)


@pytest.fixture(scope='session')
def sphinx_test_tempdir(tmp_path_factory: Any) -> Path:
"""Temporary directory."""
Expand Down
2 changes: 0 additions & 2 deletions tests/test_builders/test_build_html_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import pytest


@pytest.mark.usefixtures('if_online')
@pytest.mark.sphinx('html', testroot='images')
def test_html_remote_images(app, status, warning):
app.build(force_all=True)
Expand All @@ -25,7 +24,6 @@ def test_html_encoded_image(app, status, warning):
assert (app.outdir / '_images/img_#1.png').exists()


@pytest.mark.usefixtures('if_online')
@pytest.mark.sphinx('html', testroot='remote-logo')
def test_html_remote_logo(app, status, warning):
app.build(force_all=True)
Expand Down
1 change: 0 additions & 1 deletion tests/test_builders/test_build_latex.py
Original file line number Diff line number Diff line change
Expand Up @@ -1424,7 +1424,6 @@ def test_latex_raw_directive(app, status, warning):
assert 'LaTeX: abc def ghi' in result


@pytest.mark.usefixtures('if_online')
@pytest.mark.sphinx('latex', testroot='images')
def test_latex_images(app, status, warning):
with http_server(RemoteImageHandler, port=7777):
Expand Down