Open kloczek opened 7 months ago
Looks like with pytest 8.2.1 test suite is no0t able to pass collecting units
+ PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-lupa-2.1-2.fc37.x86_64/usr/lib64/python3.10/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-lupa-2.1-2.fc37.x86_64/usr/lib/python3.10/site-packages
+ /usr/bin/pytest -ra -m 'not network' lupa/tests/__init__.py lupa/tests/test.py
==================================================================================== test session starts ====================================================================================
platform linux -- Python 3.10.14, pytest-8.2.1, pluggy-1.5.0
rootdir: /home/tkloczko/rpmbuild/BUILD/lupa-lupa-2.1
configfile: pyproject.toml
plugins: flakes-4.0.5
collected 0 items / 1 error
========================================================================================== ERRORS ===========================================================================================
____________________________________________________________________________ ERROR collecting lupa/tests/test.py ____________________________________________________________________________
ImportError while importing test module '/home/tkloczko/rpmbuild/BUILD/lupa-lupa-2.1/lupa/tests/test.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
/usr/lib64/python3.10/importlib/__init__.py:126: in import_module
return _bootstrap._gcd_import(name[level:], package, level)
lupa/tests/test.py:2318: in <module>
@lupa.unpacks_lua_table
lupa/__init__.py:88: in __getattr__
lua = _newest_lib if _newest_lib is not None else _import_newest_lib()
lupa/__init__.py:65: in _import_newest_lib
_newest_lib = __import__(module_name[0], level=1, fromlist="*", globals=globals())
E ModuleNotFoundError: No module named 'lupa.lua'
================================================================================== short test summary info ==================================================================================
ERROR lupa/tests/test.py
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
===================================================================================== 1 error in 0.24s ======================================================================================
Just FTR .. tested 2.2 and pytest still fails the same way.
I don't use pytest myself. Try python -m unittest -v lupa.tests.suite
.
Correctly written unittest based test suite is correctly handled by pytest. What is the propose of importing module in such strange way? 🤔
What is the propose of importing module in such strange way? 🤔
I can't find anything particularly strange about it, but the test suite is generated, or rather duplicated, for each Lua version module. Maybe that explains why it's not just a trivial import.
_newest_lib = __import__(module_name[0], level=1, fromlist="*", globals=globals())
That line imports the Lua module with the latest available version, after putting some effort into selecting it. It's a bit more than a simple import since it needs to work regardless of the number and versions of available Lua modules.
So why this import fails? 🤔
I'm packaging your module as an rpm package so I'm using the typical PEP517 based build, install and test cycle used on building packages from non-root account.
python3 -sBm build -w --no-isolation
build
with--no-isolation
I'm using during all processes only locally installed modulesinstaller
modulecut off from access to the public network
(pytest is executed with-m "not network"
)Here is pytest output:
```console + PYTHONPATH=/home/tkloczko/rpmbuild/BUILDROOT/python-lupa-2.1-2.fc37.x86_64/usr/lib64/python3.10/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-lupa-2.1-2.fc37.x86_64/usr/lib/python3.10/site-packages + /usr/bin/pytest -ra -m 'not network' --import-mode=importlib lupa/tests/__init__.py lupa/tests/test.py ==================================================================================== test session starts ==================================================================================== platform linux -- Python 3.10.14, pytest-8.1.1, pluggy-1.4.0 rootdir: /home/tkloczko/rpmbuild/BUILD/lupa-lupa-2.1 configfile: pyproject.toml collected 317 items lupa/tests/test.py .................................................................................................................................................................. [ 51%] ...................................................................................................sssssssssss...............F............................. [100%] ========================================================================================= FAILURES ========================================================================================== ____________________________________________________________________________ TestOverflowMixin.test_no_overflow _____________________________________________________________________________ self =List of installed modules in build env:
```console Package Version ------------------ ----------- build 1.2.1 Cython 3.0.10 exceptiongroup 1.1.3 importlib_metadata 7.1.0 iniconfig 2.0.0 installer 0.7.0 packaging 24.0 pluggy 1.4.0 pyproject_hooks 1.0.0 pytest 8.1.1 python-dateutil 2.9.0.post0 setuptools 69.2.0 tokenize_rt 5.2.0 tomli 2.0.1 wheel 0.43.0 zipp 3.18.1 ```Please let me know if you need more details or want me to perform some diagnostics.