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

2.1: pytest fails in lupa/tests/test.py::TestOverflowMixin::test_no_overflow unit #266

Open
kloczek opened this issue Apr 9, 2024 · 8 comments

Comments

@kloczek
Copy link

kloczek commented Apr 9, 2024

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
  • because I'm calling build with --no-isolation I'm using during all processes only locally installed modules
  • install .whl file in </install/prefix> using installer module
  • run pytest with $PYTHONPATH pointing to sitearch and sitelib inside </install/prefix>
  • build is performed in env which is cut off from access to the public network (pytest is executed with -m "not network")
Here is pytest output:
+ 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 = <lupa.tests.test.TestOverflowMixin object at 0x7ff4c25a3280>

    def test_no_overflow(self):
>       self.assertMathType(0, 'integer')

lupa/tests/test.py:2941:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <lupa.tests.test.TestOverflowMixin object at 0x7ff4c25a3280>, number = 0, math_type = 'integer'

    def assertMathType(self, number, math_type):
>       self.assertEqual(self.lua_type(number), 'number')
E       AttributeError: 'TestOverflowMixin' object has no attribute 'assertEqual'

lupa/tests/test.py:2956: AttributeError
================================================================================== short test summary info ==================================================================================
SKIPPED [1] lupa/tests/test.py:2725: No FastRLock implementation found
SKIPPED [1] lupa/tests/test.py:2610: No FastRLock implementation found
SKIPPED [1] lupa/tests/test.py:2584: No FastRLock implementation found
SKIPPED [1] lupa/tests/test.py:2589: No FastRLock implementation found
SKIPPED [1] lupa/tests/test.py:2580: No FastRLock implementation found
SKIPPED [1] lupa/tests/test.py:2714: No FastRLock implementation found
SKIPPED [1] lupa/tests/test.py:2693: No FastRLock implementation found
SKIPPED [1] lupa/tests/test.py:2702: No FastRLock implementation found
SKIPPED [1] lupa/tests/test.py:2642: No FastRLock implementation found
SKIPPED [1] lupa/tests/test.py:2595: No FastRLock implementation found
SKIPPED [1] lupa/tests/test.py:2600: No FastRLock implementation found
FAILED lupa/tests/test.py::TestOverflowMixin::test_no_overflow - AttributeError: 'TestOverflowMixin' object has no attribute 'assertEqual'
======================================================================== 1 failed, 305 passed, 11 skipped in 13.76s =========================================================================
List of installed modules in build env:
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.

@kloczek
Copy link
Author

kloczek commented May 27, 2024

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 ======================================================================================

@kloczek
Copy link
Author

kloczek commented Jun 2, 2024

Just FTR .. tested 2.2 and pytest still fails the same way.

@scoder
Copy link
Owner

scoder commented Jun 2, 2024

I don't use pytest myself. Try python -m unittest -v lupa.tests.suite.

@kloczek
Copy link
Author

kloczek commented Jun 2, 2024

Correctly written unittest based test suite is correctly handled by pytest.
What is the propose of importing module in such strange way? 🤔

@scoder
Copy link
Owner

scoder commented Jun 3, 2024

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.

@kloczek
Copy link
Author

kloczek commented Jun 3, 2024

_newest_lib = __import__(module_name[0], level=1, fromlist="*", globals=globals())

@scoder
Copy link
Owner

scoder commented Jun 3, 2024

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.

@kloczek
Copy link
Author

kloczek commented Jun 3, 2024

So why this import fails? 🤔

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

2 participants