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

TST BUG: Tests fail in sandboxed environment #155

Open
lovesegfault opened this issue Oct 7, 2022 · 8 comments
Open

TST BUG: Tests fail in sandboxed environment #155

lovesegfault opened this issue Oct 7, 2022 · 8 comments
Labels

Comments

@lovesegfault
Copy link

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.

@bsipocz
Copy link
Member

bsipocz commented Oct 7, 2022

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',

@bsipocz bsipocz added the bug label Oct 7, 2022
@bsipocz bsipocz changed the title Tests fail in sandboxed environment TST BUG: Tests fail in sandboxed environment Oct 7, 2022
@bsipocz
Copy link
Member

bsipocz commented Oct 7, 2022

@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.

@lovesegfault
Copy link
Author

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: NixOS/nixpkgs#194973

@bsipocz
Copy link
Member

bsipocz commented Oct 7, 2022

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.

@pllim
Copy link
Member

pllim commented Oct 7, 2022

👍 to marking as remote and (optionally) open follow-up issue to see if it can run offline in the future.

@pllim
Copy link
Member

pllim commented Oct 13, 2022

@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
Copy link
Author

@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 :)

@pllim
Copy link
Member

pllim commented Oct 13, 2022

You would need to add pytest-remotedata (https://github.com/astropy/pytest-remotedata) here:

Then you can use it like this:

import pytest

@pytest.mark.remote_data
def some_test_that_needs_internet():
    # Much internet, so remote

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants