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

PyTest fails to run tests: #3561

Open
yurivict opened this issue Sep 19, 2024 · 0 comments
Open

PyTest fails to run tests: #3561

yurivict opened this issue Sep 19, 2024 · 0 comments

Comments

@yurivict
Copy link

Problem description

PyTest fails to run tests. For example:

$ pytest test_text_analysis.py
==================================================================================== test session starts ====================================================================================
platform freebsd14 -- Python 3.11.9, pytest-8.1.1, pluggy-1.5.0
rootdir: /usr/ports/textproc/py-gensim/work-py311/gensim-4.3.3
configfile: pyproject.toml
plugins: hypothesis-6.98.18, time-machine-2.11.0, flaky-3.8.1, xdist-3.6.1, timeout-2.1.0, rerunfailures-11.1.2, cov-5.0.0, aspectlib-2.0.0, subprocess-1.5.2, anyio-4.4.0, respx-0.21.1, pytest_httpserver-1.0.12, asyncio-0.23.8
asyncio: mode=Mode.STRICT
collected 0 items / 1 error                                                                                                                                                                 

========================================================================================== ERRORS ===========================================================================================
____________________________________________________________________ ERROR collecting gensim/test/test_text_analysis.py _____________________________________________________________________
../matutils.py:1356: in <module>
    from gensim.corpora._mmreader import MmReader  # noqa: F401
E   ModuleNotFoundError: No module named 'gensim.corpora._mmreader'

During handling of the above exception, another exception occurred:
/usr/local/lib/python3.11/site-packages/pytest_asyncio/plugin.py:644: in _patched_collect
    module = collector.obj
/usr/local/lib/python3.11/site-packages/_pytest/python.py:315: in obj
    self._obj = obj = self._getobj()
/usr/local/lib/python3.11/site-packages/_pytest/python.py:573: in _getobj
    return importtestmodule(self.path, self.config)
/usr/local/lib/python3.11/site-packages/_pytest/python.py:520: in importtestmodule
    mod = import_path(
/usr/local/lib/python3.11/site-packages/_pytest/pathlib.py:584: in import_path
    importlib.import_module(module_name)
/usr/local/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>:1126: in _find_and_load_unlocked
    ???
<frozen importlib._bootstrap>:241: in _call_with_frames_removed
    ???
<frozen importlib._bootstrap>:1204: in _gcd_import
    ???
<frozen importlib._bootstrap>:1176: in _find_and_load
    ???
<frozen importlib._bootstrap>:1126: in _find_and_load_unlocked
    ???
<frozen importlib._bootstrap>:241: in _call_with_frames_removed
    ???
<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
    ???
<frozen importlib._bootstrap_external>:940: in exec_module
    ???
<frozen importlib._bootstrap>:241: in _call_with_frames_removed
    ???
../__init__.py:11: in <module>
    from gensim import parsing, corpora, matutils, interfaces, models, similarities, utils  # noqa:F401
../corpora/__init__.py:6: in <module>
    from .indexedcorpus import IndexedCorpus  # noqa:F401 must appear before the other classes
../corpora/indexedcorpus.py:14: in <module>
    from gensim import interfaces, utils
../interfaces.py:19: in <module>
    from gensim import utils, matutils
../matutils.py:1359: in <module>
    raise utils.NO_CYTHON
E   RuntimeError: Compiled extensions are unavailable. If you've installed from a package, ask the package maintainer to include compiled extensions. If you're building Gensim from source yourself, install Cython and a C compiler, and then run `python setup.py build_ext --inplace` to retry.
-------------------------------------------------------------------------------------- Captured stdout --------------------------------------------------------------------------------------
gensim/matutils.py: exc=No module named 'gensim.corpora._mmreader'
================================================================================== short test summary info ==================================================================================
ERROR test_text_analysis.py - RuntimeError: Compiled extensions are unavailable. If you've installed from a package, ask the package maintainer to include compiled extensions. If you're building Gensim from source ...
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
===================================================================================== 1 error in 4.56s ======================================================================================

The error is caused by this import statement: from gensim.corpora._mmreader import MmReader
However, this import succeeds when done from the Python interpreter.
It only fails under PyTest.

This tests succeeds when run from Python:

$ python3.11 test_text_analysis.py
............
----------------------------------------------------------------------
Ran 12 tests in 0.309s

OK

Steps/code/corpus to reproduce

gensim is built and installed in a standard way, like all other python packages.
It seems to function fine. Each test passes when run separately from the python interpreter.

Test infrastructure itself seems to be broken.

Versions

FreeBSD-14.1-STABLE-amd64-64bit-ELF
Python 3.11.9 (main, Jul 11 2024, 01:05:32) [Clang 16.0.6 (https://github.com/llvm/llvm-project.git llvmorg-16.0.6-0-g7cbf1a
Bits 64
NumPy 1.26.4
SciPy 1.11.1
gensim 4.3.3
FAST_VERSION 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant