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

Test failure AutoImportTest.test_search_submodule: AssertionError: ('from build import env', 'env') not found in [] #478

Closed
jgarte opened this issue May 27, 2022 · 4 comments · Fixed by #755
Labels
affected-version:1.1 bug Unexpected or incorrect user-visible behavior

Comments

@jgarte
Copy link

jgarte commented May 27, 2022

Hi, does anyone know why this test might be failing?

======================================================================
FAIL: test_search_submodule (ropetest.contrib.autoimporttest.AutoImportTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/tmp/guix-build-python-rope-1.1.1.drv-0/rope-1.1.1/ropetest/contrib/autoimporttest.py", line 121, in test_search_submodule
    self.assertIn(import_statement, self.importer.search("env", exact_match=True))
AssertionError: ('from build import env', 'env') not found in []

----------------------------------------------------------------------
Ran 1892 tests in 14.880s

FAILED (failures=1, skipped=33, expected failures=1)
Test failed: <unittest.runner.TextTestResult run=1892 errors=0 failures=1>
error: Test failed: <unittest.runner.TextTestResult run=1892 errors=0 failures=1>
error: in phase 'check': uncaught exception:
%exception #<&invoke-error program: "python" arguments: ("-c" "import setuptools, tokenize;__file__='setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\\r\\n', '\\n');f.close();exec(compile(code, __file__, 'exec'))" "test") exit-status: 1 term-signal: #f stop-signal: #f>
phase `check' failed after 16.4 seconds
command "python" "-c" "import setuptools, tokenize;__file__='setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\\r\\n', '\\n');f.close();exec(compile(code, __file__, 'exec'))" "test" failed with status 1
builder for `/gnu/store/pgkjsi2i9yksi5cd4ymi9xpxbnnzlj7z-python-rope-1.1.1.drv' failed with exit code 1
build of /gnu/store/pgkjsi2i9yksi5cd4ymi9xpxbnnzlj7z-python-rope-1.1.1.drv failed
Could not find build log for '/gnu/store/pgkjsi2i9yksi5cd4ymi9xpxbnnzlj7z-python-rope-1.1.1.drv'.
guix build: error: build of `/gnu/store/pgkjsi2i9yksi5cd4ymi9xpxbnnzlj7z-python-rope-1.1.1.drv' failed

@jgarte jgarte added the bug Unexpected or incorrect user-visible behavior label May 27, 2022
@lieryan
Copy link
Member

lieryan commented May 27, 2022

Hi @jgarte,

If you want to run rope's unittests, make sure you install the additional dev dependencies (i.e. pip installl rope[dev] or equivalent). This will install additional development dependencies that necessary when running tests, in particular build and pytest-timeout.

See setup.py (or in the future, pyproject.toml) for the full, most up to date list of additional dev dependencies.

@lieryan
Copy link
Member

lieryan commented May 27, 2022

Having said that, we might want to actually rewrite this test to not depend on build. This particular test do need to run against some third party libraries though, as it's testing autoimport of third party library and build just happens to be conveniently installed in the test system.

Maybe we can isolate this by rewriting the test to try to import something from pytest instead or to install a dummy package for the sole purpose of the test.

@bagel897
Copy link
Contributor

It requires a submodule to be there - ie the package must have more than one file. build is problematic because

  1. The user may not have it installed
  2. It only has two files
  3. Sometimes, pip/setuptools will create a build directory in sys.path and autoimport won't find build. That is a separate (but very rare) bug.

Pytest has a different issues:

  1. The only public module is main which doesn't have anything to import in it (and is ignored by autoimport)
  2. The private module _pytest is a bad idea because it is private and therefore unstable. Also autoimport ignores private modules by default.

Therefore, pytest won't satisfy the testing requirements.

@lieryan lieryan changed the title Test fails Test failure AutoImportTest.test_search_submodule: AssertionError: ('from build import env', 'env') not found in [] Jul 12, 2022
@lieryan lieryan added this to the 1.3.0 milestone Jul 12, 2022
@lieryan lieryan modified the milestones: 1.3.0, 1.4.0 Jul 29, 2022
@lieryan lieryan modified the milestones: 1.4.0, 1.5.0 Oct 21, 2022
@lieryan lieryan modified the milestones: 1.5.0, 1.6.0 Nov 22, 2022
@lieryan lieryan modified the milestones: 1.6.0, 1.7.0 Dec 15, 2022
@lieryan lieryan removed this from the 1.7.0 milestone Jan 17, 2023
@lieryan lieryan added this to Kanban Jan 17, 2023
@lieryan lieryan moved this to 🆕 New in Kanban Jan 17, 2023
@github-project-automation github-project-automation bot moved this from 🆕 New to ✅ Done in Kanban Feb 13, 2024
@lieryan
Copy link
Member

lieryan commented Feb 13, 2024

This should be fixed now in #755.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affected-version:1.1 bug Unexpected or incorrect user-visible behavior
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

3 participants