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

0.3.9: pytest fails with errors because missing test_* modules #685

Closed
kloczek opened this issue Oct 1, 2024 · 4 comments
Closed

0.3.9: pytest fails with errors because missing test_* modules #685

kloczek opened this issue Oct 1, 2024 · 4 comments
Milestone

Comments

@kloczek
Copy link
Contributor

kloczek commented Oct 1, 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-dill-0.3.9-2.fc37.x86_64/usr/lib64/python3.10/site-packages:/home/tkloczko/rpmbuild/BUILDROOT/python-dill-0.3.9-2.fc37.x86_64/usr/lib/python3.10/site-packages
+ /usr/bin/pytest -ra -m 'not network'
==================================================================================== test session starts ====================================================================================
platform linux -- Python 3.10.14, pytest-8.2.2, pluggy-1.5.0
rootdir: /home/tkloczko/rpmbuild/BUILD/dill-0.3.9
configfile: pyproject.toml
plugins: typeguard-4.3.0, hypothesis-6.100.0, mock-3.14.0, asyncio-0.23.8
asyncio: mode=strict
collected 91 items / 7 errors

========================================================================================== ERRORS ===========================================================================================
_________________________________________________________________________ ERROR collecting dill/tests/test_diff.py __________________________________________________________________________
dill/tests/test_diff.py:9: in <module>
    from dill import __diff as diff
dill/__diff.py:233: in <module>
    memorise(mod)
dill/__diff.py:111: in memorise
    [mem(value) for key, value in g.items()]
dill/__diff.py:111: in <listcomp>
    [mem(value) for key, value in g.items()]
dill/__diff.py:119: in memorise
    [mem(item) for item in s]
dill/__diff.py:119: in <listcomp>
    [mem(item) for item in s]
dill/__diff.py:111: in memorise
    [mem(value) for key, value in g.items()]
dill/__diff.py:111: in <listcomp>
    [mem(value) for key, value in g.items()]
dill/__diff.py:111: in memorise
    [mem(value) for key, value in g.items()]
dill/__diff.py:111: in <listcomp>
    [mem(value) for key, value in g.items()]
dill/__diff.py:111: in memorise
    [mem(value) for key, value in g.items()]
dill/__diff.py:111: in <listcomp>
    [mem(value) for key, value in g.items()]
dill/__diff.py:115: in memorise
    [(mem(key), mem(item))
dill/__diff.py:115: in <listcomp>
    [(mem(key), mem(item))
dill/__diff.py:111: in memorise
    [mem(value) for key, value in g.items()]
dill/__diff.py:111: in <listcomp>
    [mem(value) for key, value in g.items()]
dill/__diff.py:111: in memorise
    [mem(value) for key, value in g.items()]
dill/__diff.py:111: in <listcomp>
    [mem(value) for key, value in g.items()]
dill/__diff.py:111: in memorise
    [mem(value) for key, value in g.items()]
dill/__diff.py:111: in <listcomp>
    [mem(value) for key, value in g.items()]
dill/__diff.py:111: in memorise
    [mem(value) for key, value in g.items()]
dill/__diff.py:111: in <listcomp>
    [mem(value) for key, value in g.items()]
dill/__diff.py:111: in memorise
    [mem(value) for key, value in g.items()]
dill/__diff.py:111: in <listcomp>
    [mem(value) for key, value in g.items()]
dill/__diff.py:111: in memorise
    [mem(value) for key, value in g.items()]
dill/__diff.py:111: in <listcomp>
    [mem(value) for key, value in g.items()]
dill/__diff.py:101: in memorise
    seq_id = dict((id_(key),id_(value)) for key, value in s.items())
dill/__diff.py:101: in <genexpr>
    seq_id = dict((id_(key),id_(value)) for key, value in s.items())
E   ValueError: too many values to unpack (expected 2)
________________________________________________________________________ ERROR collecting dill/tests/test_module.py _________________________________________________________________________
ImportError while importing test module '/home/tkloczko/rpmbuild/BUILD/dill-0.3.9/dill/tests/test_module.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)
dill/tests/test_module.py:11: in <module>
    import test_mixins as module
dill/__diff.py:220: in _imp
    mod = __import__(*args, **kwds)
E   ModuleNotFoundError: No module named 'test_mixins'
________________________________________________________________________ ERROR collecting dill/tests/test_objects.py ________________________________________________________________________
dill/tests/test_objects.py:20: in <module>
    load_types(pickleable=True,unpickleable=False)
dill/__init__.py:71: in load_types
    from . import _objects
dill/__diff.py:223: in _imp
    memorise(sys.modules[m])
dill/__diff.py:111: in memorise
    [mem(value) for key, value in g.items()]
dill/__diff.py:111: in <listcomp>
    [mem(value) for key, value in g.items()]
dill/__diff.py:115: in memorise
    [(mem(key), mem(item))
dill/__diff.py:115: in <listcomp>
    [(mem(key), mem(item))
dill/__diff.py:91: in memorise
    g = get_attrs(obj)
dill/__diff.py:44: in get_attrs
    return getattr(obj, '__dict__', None)
E   ReferenceError: weakly-referenced object no longer exists
______________________________________________________________________ ERROR collecting dill/tests/test_registered.py _______________________________________________________________________
dill/tests/test_registered.py:45: in <module>
    raise e from None
dill/tests/test_registered.py:42: in <module>
    assert not bool(success)
E   AssertionError: assert not True
E    +  where True = bool(['PrettyPrinterType', 'StreamHandlerType'])
-------------------------------------------------------------------------------------- Captured stdout --------------------------------------------------------------------------------------
SUCCESS: ['PrettyPrinterType', 'StreamHandlerType']
_______________________________________________________________________ ERROR collecting dill/tests/test_selected.py ________________________________________________________________________
dill/tests/test_selected.py:46: in <module>
    objects['TemporaryFileType'].close()
E   OSError: [Errno 9] Bad file descriptor
________________________________________________________________________ ERROR collecting dill/tests/test_session.py ________________________________________________________________________
ImportError while importing test module '/home/tkloczko/rpmbuild/BUILD/dill-0.3.9/dill/tests/test_session.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)
dill/tests/test_session.py:72: in <module>
    import test_dictviews as local_mod                  # non-builtin top-level module
dill/__diff.py:220: in _imp
    mod = __import__(*args, **kwds)
E   ModuleNotFoundError: No module named 'test_dictviews'
________________________________________________________________________ ERROR collecting dill/tests/test_sources.py ________________________________________________________________________
ImportError while importing test module '/home/tkloczko/rpmbuild/BUILD/dill-0.3.9/dill/tests/test_sources.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)
dill/tests/test_sources.py:34: in <module>
    import test_source as ts
dill/__diff.py:220: in _imp
    mod = __import__(*args, **kwds)
E   ModuleNotFoundError: No module named 'test_source'
================================================================================== short test summary info ==================================================================================
ERROR dill/tests/test_diff.py - ValueError: too many values to unpack (expected 2)
ERROR dill/tests/test_module.py
ERROR dill/tests/test_objects.py - ReferenceError: weakly-referenced object no longer exists
ERROR dill/tests/test_registered.py - AssertionError: assert not True
ERROR dill/tests/test_selected.py - OSError: [Errno 9] Bad file descriptor
ERROR dill/tests/test_session.py
ERROR dill/tests/test_sources.py
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 7 errors during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
===================================================================================== 7 errors in 2.13s =====================================================================================

Please let me know if you need more details or want me to perform some diagnostics.

@kloczek
Copy link
Contributor Author

kloczek commented Oct 1, 2024

Also looks like test suite is now part of the installed resources.
Easiest way to fix that would be move dill/tests/ to tests/.

@mmckerns mmckerns added this to the dill-0.4.0 milestone Oct 1, 2024
@mmckerns
Copy link
Member

mmckerns commented Oct 1, 2024

This is known and a duplicate of #460. Also, the inclusion of the tests is intentional. As this is becoming more and more of a community standard, I may not be able to ignore it... I'll need to find out if pytest has gained better capacity to work with codes intended for parallel and other out-of-process elements. I'm going to close the issue, as it's a duplicate.

@mmckerns mmckerns closed this as completed Oct 1, 2024
@mmckerns
Copy link
Member

mmckerns commented Oct 1, 2024

I appreciate the details on your pytest config, btw.

@kloczek
Copy link
Contributor Author

kloczek commented Oct 1, 2024

I'm using pytest setting which are come with git tree.
Did you try to reproduce this issue using command which I've provided? 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants