sphinx-automodapi
sphinx-automodapi copied to clipboard
TST BUG: Tests fail in sandboxed environment
Almost all the tests fail inside a sandboxed build environment because they require network access for some reason. The error is always the same:
python3.10-sphinx-automodapi> Warning, treated as error:
python3.10-sphinx-automodapi> failed to reach any of the inventories with the following issues:
python3.10-sphinx-automodapi> intersphinx inventory 'https://docs.python.org/3/objects.inv' not fetchable due to <class 'requests.exceptions.ConnectionError'>: HTTPSConnectionPool(host='docs.python.org', port=443): Max retries exceeded with url: /3/objects.inv (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7ffff439d840>: Failed to establish a new connection: [Errno -3] Temporary failure in name resolution'))
I would appreciate it if there was a way to manually provide this objects.inv file, so that tests could still run without network access.
I guess we can start using pytest-remotedata to make sure tests can run locally.
However here is an immediate patch for your use case for now, where I simply wget-ed the most up-to-date objects.inv file to /tmp. But if you have sphinx_astropy installed as well, then you can use its copy, too (it maybe a bit outdated version though):
site-packages/sphinx_astropy/local/python3_local_links.inv
diff --git a/sphinx_automodapi/tests/helpers.py b/sphinx_automodapi/tests/helpers.py
index 5fb34a0..ede4b3e 100644
--- a/sphinx_automodapi/tests/helpers.py
+++ b/sphinx_automodapi/tests/helpers.py
@@ -12,7 +12,7 @@ __all__ = ['write_conf', 'run_sphinx_in_tmpdir']
intersphinx_mapping = {
- 'python': ('https://docs.python.org/3/', None)
+ 'python': ('https://docs.python.org/3/', (None, '/tmp/objects.inv'))
}
DEFAULT_CONF = {'source_suffix': '.rst',
@pllim - I'm kind of inclined towards decorating the tests as online tests and call it a day (and having CI run all but on job with online enabled) rather than adding a local intersphinx file here. After all, the feature of adding alternative locations is not a sphinx-automodapi feature and should have been tested upstream already.
Personally, I would be more than satisfied if it checked for a INTERSPHINX_MAPPING_FILE env var and used that if it's set.
You both know what's best for your project, naturally :)
With your suggestion, I've already been able to get the tests running for nixpkgs, which was my goal: https://github.com/NixOS/nixpkgs/pull/194973
yeah, I wonder why it never came up as a problem for e.g. debian packaging testing, anyway, we have the machinery to enforce tests not to run when there is no online connection, that will probably be the solution for here.
👍 to marking as remote and (optionally) open follow-up issue to see if it can run offline in the future.
@lovesegfault , do you have a list of the failed tests in sandboxed env? I can mark them or a PR is also very welcome. Thanks!
@lovesegfault , do you have a list of the failed tests in sandboxed env? I can mark them or a PR is also very welcome. Thanks!
If you show me how to mark them, I can roll back the patch where I fixed this in nixpkgs, collect a build failure, and make a PR adding the markings :)
You would need to add pytest-remotedata (https://github.com/astropy/pytest-remotedata) here:
https://github.com/astropy/sphinx-automodapi/blob/c4aa83731cf785cb8ad1bee982f15b25f316775a/setup.cfg#L26
Then you can use it like this:
import pytest
@pytest.mark.remote_data
def some_test_that_needs_internet():
# Much internet, so remote