Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 921119 - dev-python/bcrypt-4.1.2 fails tests: ERROR collecting tests/test_bcrypt.py
Summary: dev-python/bcrypt-4.1.2 fails tests: ERROR collecting tests/test_bcrypt.py
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: Python Gentoo Team
URL:
Whiteboard:
Keywords: TESTFAILURE
Depends on:
Blocks:
 
Reported: 2023-12-31 10:28 UTC by Dustin Polke
Modified: 2024-01-02 19:28 UTC (History)
4 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
emerge --info (emerge--info.txt,20.88 KB, text/plain)
2023-12-31 10:28 UTC, Dustin Polke
Details
Full build.log (build.log,69.83 KB, text/plain)
2023-12-31 10:30 UTC, Dustin Polke
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Dustin Polke 2023-12-31 10:28:58 UTC
Created attachment 881089 [details]
emerge --info

Test phase fails as follows:

>>> Test phase: dev-python/bcrypt-4.1.2
 * python3_11: running distutils-r1_run_phase python_test
python3.11 -m pytest -vv -ra -l -Wdefault --color=yes -o console_output_style=count -p no:cov -p no:flake8 -p no:flakes -p no:pylint -p no:markdown -p no:sugar -p no:xvfb -p no:pytest-describe -p no:plus -p no:tavern -p no:salt-factories
================================================================================ test session starts =================================================================================
platform linux -- Python 3.11.7, pytest-7.4.3, pluggy-1.3.0 -- /var/tmp/portage/dev-python/bcrypt-4.1.2/work/bcrypt-4.1.2-python3_11/install/usr/bin/python3.11
cachedir: .pytest_cache
hypothesis profile 'default' -> database=DirectoryBasedExampleDatabase(PosixPath('/var/tmp/portage/dev-python/bcrypt-4.1.2/work/bcrypt-4.1.2/.hypothesis/examples'))
rootdir: /var/tmp/portage/dev-python/bcrypt-4.1.2/work/bcrypt-4.1.2
plugins: regressions-2.5.0, xprocess-0.23.0, xdist-3.5.0, typeguard-4.1.5, freezegun-0.4.2, timeout-2.2.0, pyfakefs-5.3.2, flaky-3.7.0, Faker-21.0.0, virtualenv-1.7.0, tornasync-0.6.0.post2, console-scripts-1.4.1, trio-0.8.0, hypothesis-6.92.0, httpserver-1.0.8, httpbin-2.0.0, jaraco.test-5.3.0, datadir-1.5.0, forked-1.6.0, subtests-0.11.0, pkgcore-0.12.24, expect-1.1.0, rerunfailures-13.0, asyncio-0.23.2, mock-3.12.0, anyio-4.1.0, shutil-1.7.0, time-machine-2.13.0, aiohttp-1.0.5
asyncio: mode=Mode.STRICT
collecting ... collected 0 items / 1 error

======================================================================================= ERRORS =======================================================================================
_______________________________________________________________________ ERROR collecting tests/test_bcrypt.py ________________________________________________________________________
ImportError while importing test module '/var/tmp/portage/dev-python/bcrypt-4.1.2/work/bcrypt-4.1.2/tests/test_bcrypt.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/usr/lib/python3.11/site-packages/_pytest/python.py:617: in _importtestmodule
    mod = import_path(self.path, mode=importmode, root=self.config.rootpath)
/usr/lib/python3.11/site-packages/_pytest/pathlib.py:567: in import_path
    importlib.import_module(module_name)
/usr/lib/python3.11/importlib/__init__.py:126: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
<frozen importlib._bootstrap>:1204: in _gcd_import
    ???
<frozen importlib._bootstrap>:1176: in _find_and_load
    ???
<frozen importlib._bootstrap>:1147: in _find_and_load_unlocked
    ???
<frozen importlib._bootstrap>:690: in _load_unlocked
    ???
/usr/lib/python3.11/site-packages/_pytest/assertion/rewrite.py:186: in exec_module
    exec(co, module.__dict__)
tests/test_bcrypt.py:3: in <module>
    import bcrypt
src/bcrypt/__init__.py:13: in <module>
    from ._bcrypt import (
E   ModuleNotFoundError: No module named 'bcrypt._bcrypt'
============================================================================== short test summary info ===============================================================================
ERROR tests/test_bcrypt.py
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
================================================================================== 1 error in 0.38s ==================================================================================
pytest-xprocess reminder::Be sure to terminate the started process by running 'pytest --xkill' if you have not explicitly done so in your fixture with 'xprocess.getinfo(<process_name>).terminate()'.
 * ERROR: dev-python/bcrypt-4.1.2::gentoo failed (test phase):
 *   pytest failed with python3.11
 * 
 * Call stack:
 *     ebuild.sh, line  136:  Called src_test
 *   environment, line 4395:  Called distutils-r1_src_test
 *   environment, line 2338:  Called _distutils-r1_run_foreach_impl 'python_test'
 *   environment, line  892:  Called python_foreach_impl 'distutils-r1_run_phase' 'python_test'
 *   environment, line 3999:  Called multibuild_foreach_variant '_python_multibuild_wrapper' 'distutils-r1_run_phase' 'python_test'
 *   environment, line 3454:  Called _multibuild_run '_python_multibuild_wrapper' 'distutils-r1_run_phase' 'python_test'
 *   environment, line 3452:  Called _python_multibuild_wrapper 'distutils-r1_run_phase' 'python_test'
 *   environment, line 1389:  Called distutils-r1_run_phase 'python_test'
 *   environment, line 2261:  Called python_test
 *   environment, line 4282:  Called distutils-r1_python_test
 *   environment, line 2201:  Called epytest
 *   environment, line 2876:  Called die
 * The specific snippet of code:
 *       "${@}" || die -n "pytest failed with ${EPYTHON}";
 * 
 * If you need support, post the output of `emerge --info '=dev-python/bcrypt-4.1.2::gentoo'`,
 * the complete build log and the output of `emerge -pqv '=dev-python/bcrypt-4.1.2::gentoo'`.
 * The complete build log is located at '/var/tmp/portage/dev-python/bcrypt-4.1.2/temp/build.log'.
 * The ebuild environment file is located at '/var/tmp/portage/dev-python/bcrypt-4.1.2/temp/environment'.
 * Working directory: '/var/tmp/portage/dev-python/bcrypt-4.1.2/work/bcrypt-4.1.2'
 * S: '/var/tmp/portage/dev-python/bcrypt-4.1.2/work/bcrypt-4.1.2'
Comment 1 Dustin Polke 2023-12-31 10:30:55 UTC
Created attachment 881090 [details]
Full build.log
Comment 2 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2024-01-01 10:58:03 UTC
I wonder why it's trying to import stuff from "src" for you, that's not expected behavior.

Do you have PYTHONPATH set?

Could you try running it via:

PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 emerge -v dev-python/bcrypt

?
Comment 3 Dustin Polke 2024-01-01 20:11:20 UTC
Just tried as you requested.

PYTHONPATH is not set.
Test succeeded with PYTEST_DISABLE_PLUGIN_AUTOLOAD=1.
Comment 4 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2024-01-01 20:39:31 UTC
That's weird.  You don't seem to have installed any plugins that I don't have, yet I can't reproduce the problem.
Comment 5 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2024-01-02 04:10:16 UTC
Could you try to grep a bit and see if you can find something that appends src to sys.path?

Something like:

find /usr/lib/python3.11/site-packages -name '*.py' -exec grep sys.path.*src {} +
Comment 6 Dustin Polke 2024-01-02 16:39:41 UTC
(In reply to Michał Górny from comment #5)
> Could you try to grep a bit and see if you can find something that appends
> src to sys.path?
> 
> Something like:
> 
> find /usr/lib/python3.11/site-packages -name '*.py' -exec grep sys.path.*src
> {} +

$ find /usr/lib/python3.11/site-packages -name '*.py' -exec grep sys.path.*src {} +
/usr/lib/python3.11/site-packages/pkgcheck/scripts/__init__.py:    sys.path.insert(0, src_dir)
/usr/lib/python3.11/site-packages/numpy/distutils/tests/test_build_ext.py:                sys.path.insert(0, r"{srctree}")
/usr/lib/python3.11/site-packages/fs/base.py:                src_sys_path = self.getsyspath(src_path)
/usr/lib/python3.11/site-packages/fs/compress.py:                    sys_path = src_fs.getsyspath(path)
/usr/lib/python3.11/site-packages/pkgdev/scripts/__init__.py:    sys.path.insert(0, src_dir)
/usr/lib/python3.11/site-packages/pkgcore/scripts/__init__.py:    sys.path.insert(0, src_dir)
Comment 7 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2024-01-02 16:49:56 UTC
Hmm, still no dice.  Well, my last idea would be to keep adding `-p no:<plugin>` for all plugins listed in pytest output and telling after which one the issue stops happening.  However, this is a lot of effort, so I can understand if you don't want to do that.
Comment 8 Dustin Polke 2024-01-02 17:01:58 UTC
(In reply to Michał Górny from comment #7)
> Hmm, still no dice.  Well, my last idea would be to keep adding `-p
> no:<plugin>` for all plugins listed in pytest output and telling after which
> one the issue stops happening.  However, this is a lot of effort, so I can
> understand if you don't want to do that.

I will have a look but don't understand exactly what you want me do. Could you elaborate a bit more as I don't know python.
Comment 9 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2024-01-02 17:45:49 UTC
Start by doing:

$ cd /var/tmp/portage/dev-python/bcrypt-4.1.2/work/bcrypt-4.1.2
$ /var/tmp/portage/dev-python/bcrypt-4.1.2/work/bcrypt-4.1.2-python3_11/install/usr/bin/python -m pytest

This should lead to the same failure.

Then look at the list of 'plugins:', take the first one, add `-p no:<name>` and try again, e.g.:

$ /var/tmp/portage/dev-python/bcrypt-4.1.2/work/bcrypt-4.1.2-python3_11/install/usr/bin/python -m pytest -p no:expect

and repeat adding `-p no:...` options until it stops failing.  Then let me know which command succeeded.
Comment 10 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2024-01-02 17:51:11 UTC
Actually, some plugin names don't actually match what you must pass to `-p`, sigh.  I'll come up with a simpler method in a minute.
Comment 11 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2024-01-02 18:07:11 UTC
Well, nevermind.  While preparing instructions for you, I've found a way to reproduce it.  It turns out that pytest-asyncio is causing it.  For some reason, another plugin that I have on this system is reverting this effect.  I'll continue investigating.
Comment 12 Michał Górny archtester Gentoo Infrastructure gentoo-dev Security 2024-01-02 18:26:29 UTC
I've found the root issue, reported it upstream and I'll commit a workaround to the ebuild in a minute.

Thanks a lot for reporting this!
Comment 13 Larry the Git Cow gentoo-dev 2024-01-02 19:28:30 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=2225bfaffcdde4b96416121a33a92fd6e92815da

commit 2225bfaffcdde4b96416121a33a92fd6e92815da
Author:     Michał Górny <mgorny@gentoo.org>
AuthorDate: 2024-01-02 18:26:30 +0000
Commit:     Michał Górny <mgorny@gentoo.org>
CommitDate: 2024-01-02 19:28:27 +0000

    dev-python/bcrypt: Workaround pytest-asyncio cause test failures
    
    Explicitly specify the test directory to workaround a bug
    in pytest-asyncio that causes pytest to import modules that
    do not match `python_files`.  Also disable plugin autoloading for good
    measure.
    
    Closes: https://bugs.gentoo.org/921119
    Signed-off-by: Michał Górny <mgorny@gentoo.org>

 dev-python/bcrypt/bcrypt-4.1.2.ebuild | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)