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 and relative imports #33783

Open
mkoeppe opened this issue May 1, 2022 · 0 comments
Open

pytest and relative imports #33783

mkoeppe opened this issue May 1, 2022 · 0 comments

Comments

@mkoeppe
Copy link
Contributor

mkoeppe commented May 1, 2022

(from #33531 comment:14):

Out of all the files *_test.py in sage source tree (9 files), the only one that fails to pytest is sage/structure/sage_object_test.py which gives me the following error:

=================================================================================== ERRORS ===================================================================================
____________________________________________________________ ERROR collecting sage/structure/sage_object_test.py _____________________________________________________________
ImportError while importing test module '/home/tornaria/src/sage/sage-git/src/sage/structure/sage_object_test.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
src/sage/structure/sage_object_test.py:3: in <module>
    from .sage_object import SageObject
E   ImportError: attempted relative import with no known parent package
========================================================================== short test summary info ===========================================================================
This goes away if I change the import to be absolute (sage.structure.sage_object)

CC: @tornaria @tobiasdiez

Component: refactoring

Issue created by migration from https://trac.sagemath.org/ticket/33783

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

1 participant