rope icon indicating copy to clipboard operation
rope copied to clipboard

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

Open jgarte opened this issue 3 years ago • 3 comments

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 avatar May 27 '22 03:05 jgarte

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 avatar May 27 '22 04:05 lieryan

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.

lieryan avatar May 27 '22 05:05 lieryan

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.

bagel897 avatar May 29 '22 03:05 bagel897

This should be fixed now in #755.

lieryan avatar Feb 13 '24 23:02 lieryan