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

Failing tests test_no_warnings and test_c_extension_preferred_by_default #954

Open
mcepl opened this issue Mar 6, 2024 · 4 comments
Open

Comments

@mcepl
Copy link

mcepl commented Mar 6, 2024

Long story short

When building multidict for openSUSE/Factory two tests are failing:

[   14s] =================================== FAILURES ===================================
[   14s] _________________________ test_no_warnings[multidict] __________________________
[   14s] 
[   14s] import_path = 'multidict'
[   14s] 
[   14s]     def test_no_warnings(import_path: str) -> None:
[   14s]         """Verify that importing modules and packages doesn't explode.
[   14s]     
[   14s]         This is seeking for any import errors including ones caused
[   14s]         by circular imports.
[   14s]         """
[   14s]         imp_cmd = (
[   14s]             # fmt: off
[   14s]             sys.executable,
[   14s]             "-I",
[   14s]             "-W", "error",
[   14s]             "-c", f"import {import_path!s}",
[   14s]             # fmt: on
[   14s]         )
[   14s]     
[   14s] >       subprocess.check_call(imp_cmd)
[   14s] 
[   14s] tests/test_circular_imports.py:93: 
[   14s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
[   14s] 
[   14s] popenargs = (('/usr/bin/python3.9', '-I', '-W', 'error', '-c', 'import multidict'),)
[   14s] kwargs = {}, retcode = 1
[   14s] cmd = ('/usr/bin/python3.9', '-I', '-W', 'error', '-c', 'import multidict')
[   14s] 
[   14s]     def check_call(*popenargs, **kwargs):
[   14s]         """Run command with arguments.  Wait for command to complete.  If
[   14s]         the exit code was zero then return, otherwise raise
[   14s]         CalledProcessError.  The CalledProcessError object will have the
[   14s]         return code in the returncode attribute.
[   14s]     
[   14s]         The arguments are the same as for the call function.  Example:
[   14s]     
[   14s]         check_call(["ls", "-l"])
[   14s]         """
[   14s]         retcode = call(*popenargs, **kwargs)
[   14s]         if retcode:
[   14s]             cmd = kwargs.get("args")
[   14s]             if cmd is None:
[   14s]                 cmd = popenargs[0]
[   14s] >           raise CalledProcessError(retcode, cmd)
[   14s] E           subprocess.CalledProcessError: Command '('/usr/bin/python3.9', '-I', '-W', 'error', '-c', 'import multidict')' returned non-zero exit status 1.
[   14s] 
[   14s] /usr/lib64/python3.9/subprocess.py:373: CalledProcessError
[   14s] ----------------------------- Captured stderr call -----------------------------
[   14s] Traceback (most recent call last):
[   14s]   File "<string>", line 1, in <module>
[   14s] ModuleNotFoundError: No module named 'multidict'
[   14s] _______________________ test_no_warnings[multidict._abc] _______________________
[   14s] 
[   14s] import_path = 'multidict._abc'
[   14s] 
[   14s]     def test_no_warnings(import_path: str) -> None:
[   14s]         """Verify that importing modules and packages doesn't explode.
[   14s]     
[   14s]         This is seeking for any import errors including ones caused
[   14s]         by circular imports.
[   14s]         """
[   14s]         imp_cmd = (
[   14s]             # fmt: off
[   14s]             sys.executable,
[   14s]             "-I",
[   14s]             "-W", "error",
[   14s]             "-c", f"import {import_path!s}",
[   14s]             # fmt: on
[   14s]         )
[   14s]     
[   14s] >       subprocess.check_call(imp_cmd)
[   14s] 
[   14s] tests/test_circular_imports.py:93: 
[   14s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
[   14s] 
[   14s] popenargs = (('/usr/bin/python3.9', '-I', '-W', 'error', '-c', 'import multidict._abc'),)
[   14s] kwargs = {}, retcode = 1
[   14s] cmd = ('/usr/bin/python3.9', '-I', '-W', 'error', '-c', 'import multidict._abc')
[   14s] 
[   14s]     def check_call(*popenargs, **kwargs):
[   14s]         """Run command with arguments.  Wait for command to complete.  If
[   14s]         the exit code was zero then return, otherwise raise
[   14s]         CalledProcessError.  The CalledProcessError object will have the
[   14s]         return code in the returncode attribute.
[   14s]     
[   14s]         The arguments are the same as for the call function.  Example:
[   14s]     
[   14s]         check_call(["ls", "-l"])
[   14s]         """
[   14s]         retcode = call(*popenargs, **kwargs)
[   14s]         if retcode:
[   14s]             cmd = kwargs.get("args")
[   14s]             if cmd is None:
[   14s]                 cmd = popenargs[0]
[   14s] >           raise CalledProcessError(retcode, cmd)
[   14s] E           subprocess.CalledProcessError: Command '('/usr/bin/python3.9', '-I', '-W', 'error', '-c', 'import multidict._abc')' returned non-zero exit status 1.
[   14s] 
[   14s] /usr/lib64/python3.9/subprocess.py:373: CalledProcessError
[   14s] ----------------------------- Captured stderr call -----------------------------
[   14s] Traceback (most recent call last):
[   14s]   File "<string>", line 1, in <module>
[   14s] ModuleNotFoundError: No module named 'multidict'
[   14s] _____________________ test_no_warnings[multidict._compat] ______________________
[   14s] 
[   14s] import_path = 'multidict._compat'
[   14s] 
[   14s]     def test_no_warnings(import_path: str) -> None:
[   14s]         """Verify that importing modules and packages doesn't explode.
[   14s]     
[   14s]         This is seeking for any import errors including ones caused
[   14s]         by circular imports.
[   14s]         """
[   14s]         imp_cmd = (
[   14s]             # fmt: off
[   14s]             sys.executable,
[   14s]             "-I",
[   14s]             "-W", "error",
[   14s]             "-c", f"import {import_path!s}",
[   14s]             # fmt: on
[   14s]         )
[   14s]     
[   14s] >       subprocess.check_call(imp_cmd)
[   14s] 
[   14s] tests/test_circular_imports.py:93: 
[   14s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
[   14s] 
[   14s] popenargs = (('/usr/bin/python3.9', '-I', '-W', 'error', '-c', 'import multidict._compat'),)
[   14s] kwargs = {}, retcode = 1
[   14s] cmd = ('/usr/bin/python3.9', '-I', '-W', 'error', '-c', 'import multidict._compat')
[   14s] 
[   14s]     def check_call(*popenargs, **kwargs):
[   14s]         """Run command with arguments.  Wait for command to complete.  If
[   14s]         the exit code was zero then return, otherwise raise
[   14s]         CalledProcessError.  The CalledProcessError object will have the
[   14s]         return code in the returncode attribute.
[   14s]     
[   14s]         The arguments are the same as for the call function.  Example:
[   14s]     
[   14s]         check_call(["ls", "-l"])
[   14s]         """
[   14s]         retcode = call(*popenargs, **kwargs)
[   14s]         if retcode:
[   14s]             cmd = kwargs.get("args")
[   14s]             if cmd is None:
[   14s]                 cmd = popenargs[0]
[   14s] >           raise CalledProcessError(retcode, cmd)
[   14s] E           subprocess.CalledProcessError: Command '('/usr/bin/python3.9', '-I', '-W', 'error', '-c', 'import multidict._compat')' returned non-zero exit status 1.
[   14s] 
[   14s] /usr/lib64/python3.9/subprocess.py:373: CalledProcessError
[   14s] ----------------------------- Captured stderr call -----------------------------
[   14s] Traceback (most recent call last):
[   14s]   File "<string>", line 1, in <module>
[   14s] ModuleNotFoundError: No module named 'multidict'
[   14s] ____________________ test_no_warnings[multidict._multidict] ____________________
[   14s] 
[   14s] import_path = 'multidict._multidict'
[   14s] 
[   14s]     def test_no_warnings(import_path: str) -> None:
[   14s]         """Verify that importing modules and packages doesn't explode.
[   14s]     
[   14s]         This is seeking for any import errors including ones caused
[   14s]         by circular imports.
[   14s]         """
[   14s]         imp_cmd = (
[   14s]             # fmt: off
[   14s]             sys.executable,
[   14s]             "-I",
[   14s]             "-W", "error",
[   14s]             "-c", f"import {import_path!s}",
[   14s]             # fmt: on
[   14s]         )
[   14s]     
[   14s] >       subprocess.check_call(imp_cmd)
[   14s] 
[   14s] tests/test_circular_imports.py:93: 
[   14s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
[   14s] 
[   14s] popenargs = (('/usr/bin/python3.9', '-I', '-W', 'error', '-c', 'import multidict._multidict'),)
[   14s] kwargs = {}, retcode = 1
[   14s] cmd = ('/usr/bin/python3.9', '-I', '-W', 'error', '-c', 'import multidict._multidict')
[   14s] 
[   14s]     def check_call(*popenargs, **kwargs):
[   14s]         """Run command with arguments.  Wait for command to complete.  If
[   14s]         the exit code was zero then return, otherwise raise
[   14s]         CalledProcessError.  The CalledProcessError object will have the
[   14s]         return code in the returncode attribute.
[   14s]     
[   14s]         The arguments are the same as for the call function.  Example:
[   14s]     
[   14s]         check_call(["ls", "-l"])
[   14s]         """
[   14s]         retcode = call(*popenargs, **kwargs)
[   14s]         if retcode:
[   14s]             cmd = kwargs.get("args")
[   14s]             if cmd is None:
[   14s]                 cmd = popenargs[0]
[   14s] >           raise CalledProcessError(retcode, cmd)
[   14s] E           subprocess.CalledProcessError: Command '('/usr/bin/python3.9', '-I', '-W', 'error', '-c', 'import multidict._multidict')' returned non-zero exit status 1.
[   14s] 
[   14s] /usr/lib64/python3.9/subprocess.py:373: CalledProcessError
[   14s] ----------------------------- Captured stderr call -----------------------------
[   14s] Traceback (most recent call last):
[   14s]   File "<string>", line 1, in <module>
[   14s] ModuleNotFoundError: No module named 'multidict'
[   14s] _________________ test_no_warnings[multidict._multidict_base] __________________
[   14s] 
[   14s] import_path = 'multidict._multidict_base'
[   14s] 
[   14s]     def test_no_warnings(import_path: str) -> None:
[   14s]         """Verify that importing modules and packages doesn't explode.
[   14s]     
[   14s]         This is seeking for any import errors including ones caused
[   14s]         by circular imports.
[   14s]         """
[   14s]         imp_cmd = (
[   14s]             # fmt: off
[   14s]             sys.executable,
[   14s]             "-I",
[   14s]             "-W", "error",
[   14s]             "-c", f"import {import_path!s}",
[   14s]             # fmt: on
[   14s]         )
[   14s]     
[   14s] >       subprocess.check_call(imp_cmd)
[   14s] 
[   14s] tests/test_circular_imports.py:93: 
[   14s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
[   14s] 
[   14s] popenargs = (('/usr/bin/python3.9', '-I', '-W', 'error', '-c', 'import multidict._multidict_base'),)
[   14s] kwargs = {}, retcode = 1
[   14s] cmd = ('/usr/bin/python3.9', '-I', '-W', 'error', '-c', 'import multidict._multidict_base')
[   14s] 
[   14s]     def check_call(*popenargs, **kwargs):
[   14s]         """Run command with arguments.  Wait for command to complete.  If
[   14s]         the exit code was zero then return, otherwise raise
[   14s]         CalledProcessError.  The CalledProcessError object will have the
[   14s]         return code in the returncode attribute.
[   14s]     
[   14s]         The arguments are the same as for the call function.  Example:
[   14s]     
[   14s]         check_call(["ls", "-l"])
[   14s]         """
[   14s]         retcode = call(*popenargs, **kwargs)
[   14s]         if retcode:
[   14s]             cmd = kwargs.get("args")
[   14s]             if cmd is None:
[   14s]                 cmd = popenargs[0]
[   14s] >           raise CalledProcessError(retcode, cmd)
[   14s] E           subprocess.CalledProcessError: Command '('/usr/bin/python3.9', '-I', '-W', 'error', '-c', 'import multidict._multidict_base')' returned non-zero exit status 1.
[   14s] 
[   14s] /usr/lib64/python3.9/subprocess.py:373: CalledProcessError
[   14s] ----------------------------- Captured stderr call -----------------------------
[   14s] Traceback (most recent call last):
[   14s]   File "<string>", line 1, in <module>
[   14s] ModuleNotFoundError: No module named 'multidict'
[   14s] __________________ test_no_warnings[multidict._multidict_py] ___________________
[   14s] 
[   14s] import_path = 'multidict._multidict_py'
[   14s] 
[   14s]     def test_no_warnings(import_path: str) -> None:
[   14s]         """Verify that importing modules and packages doesn't explode.
[   14s]     
[   14s]         This is seeking for any import errors including ones caused
[   14s]         by circular imports.
[   14s]         """
[   14s]         imp_cmd = (
[   14s]             # fmt: off
[   14s]             sys.executable,
[   14s]             "-I",
[   14s]             "-W", "error",
[   14s]             "-c", f"import {import_path!s}",
[   14s]             # fmt: on
[   14s]         )
[   14s]     
[   14s] >       subprocess.check_call(imp_cmd)
[   14s] 
[   14s] tests/test_circular_imports.py:93: 
[   14s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
[   14s] 
[   14s] popenargs = (('/usr/bin/python3.9', '-I', '-W', 'error', '-c', 'import multidict._multidict_py'),)
[   14s] kwargs = {}, retcode = 1
[   14s] cmd = ('/usr/bin/python3.9', '-I', '-W', 'error', '-c', 'import multidict._multidict_py')
[   14s] 
[   14s]     def check_call(*popenargs, **kwargs):
[   14s]         """Run command with arguments.  Wait for command to complete.  If
[   14s]         the exit code was zero then return, otherwise raise
[   14s]         CalledProcessError.  The CalledProcessError object will have the
[   14s]         return code in the returncode attribute.
[   14s]     
[   14s]         The arguments are the same as for the call function.  Example:
[   14s]     
[   14s]         check_call(["ls", "-l"])
[   14s]         """
[   14s]         retcode = call(*popenargs, **kwargs)
[   14s]         if retcode:
[   14s]             cmd = kwargs.get("args")
[   14s]             if cmd is None:
[   14s]                 cmd = popenargs[0]
[   14s] >           raise CalledProcessError(retcode, cmd)
[   14s] E           subprocess.CalledProcessError: Command '('/usr/bin/python3.9', '-I', '-W', 'error', '-c', 'import multidict._multidict_py')' returned non-zero exit status 1.
[   14s] 
[   14s] /usr/lib64/python3.9/subprocess.py:373: CalledProcessError
[   14s] ----------------------------- Captured stderr call -----------------------------
[   14s] Traceback (most recent call last):
[   14s]   File "<string>", line 1, in <module>
[   14s] ModuleNotFoundError: No module named 'multidict'
[   14s] ____________________ test_c_extension_preferred_by_default _____________________
[   14s] 
[   14s] monkeypatch = <_pytest.monkeypatch.MonkeyPatch object at 0x7f04d51a4550>
[   14s] 
[   14s]     @pytest.mark.c_extension
[   14s]     def test_c_extension_preferred_by_default(monkeypatch: pytest.MonkeyPatch) -> None:
[   14s]         """Verify that the C-extension is exposed by default."""
[   14s]         monkeypatch.delenv("MULTIDICT_NO_EXTENSIONS", raising=False)
[   14s]     
[   14s]         imp_cmd = (
[   14s]             # fmt: off
[   14s]             sys.executable,
[   14s]             "-I",
[   14s]             "-W", "error",
[   14s]             "-c", "import multidict; raise SystemExit(int("
[   14s]             "multidict.istr.__module__ != 'multidict._multidict' "
[   14s]             "or multidict.USE_EXTENSIONS is not True))",
[   14s]             # fmt: on
[   14s]         )
[   14s]     
[   14s] >       subprocess.check_call(imp_cmd)
[   14s] 
[   14s] tests/test_circular_imports.py:112: 
[   14s] _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
[   14s] 
[   14s] popenargs = (('/usr/bin/python3.9', '-I', '-W', 'error', '-c', "import multidict; raise SystemExit(int(multidict.istr.__module__ != 'multidict._multidict' or multidict.USE_EXTENSIONS is not True))"),)
[   14s] kwargs = {}, retcode = 1
[   14s] cmd = ('/usr/bin/python3.9', '-I', '-W', 'error', '-c', "import multidict; raise SystemExit(int(multidict.istr.__module__ != 'multidict._multidict' or multidict.USE_EXTENSIONS is not True))")
[   14s] 
[   14s]     def check_call(*popenargs, **kwargs):
[   14s]         """Run command with arguments.  Wait for command to complete.  If
[   14s]         the exit code was zero then return, otherwise raise
[   14s]         CalledProcessError.  The CalledProcessError object will have the
[   14s]         return code in the returncode attribute.
[   14s]     
[   14s]         The arguments are the same as for the call function.  Example:
[   14s]     
[   14s]         check_call(["ls", "-l"])
[   14s]         """
[   14s]         retcode = call(*popenargs, **kwargs)
[   14s]         if retcode:
[   14s]             cmd = kwargs.get("args")
[   14s]             if cmd is None:
[   14s]                 cmd = popenargs[0]
[   14s] >           raise CalledProcessError(retcode, cmd)
[   14s] E           subprocess.CalledProcessError: Command '('/usr/bin/python3.9', '-I', '-W', 'error', '-c', "import multidict; raise SystemExit(int(multidict.istr.__module__ != 'multidict._multidict' or multidict.USE_EXTENSIONS is not True))")' returned non-zero exit status 1.
[   14s] 
[   14s] /usr/lib64/python3.9/subprocess.py:373: CalledProcessError
[   14s] ----------------------------- Captured stderr call -----------------------------
[   14s] Traceback (most recent call last):
[   14s]   File "<string>", line 1, in <module>
[   14s] ModuleNotFoundError: No module named 'multidict'
[   14s] =========================== short test summary info ============================
[   14s] FAILED tests/test_circular_imports.py::test_no_warnings[multidict] - subproce...
[   14s] FAILED tests/test_circular_imports.py::test_no_warnings[multidict._abc] - sub...
[   14s] FAILED tests/test_circular_imports.py::test_no_warnings[multidict._compat] - ...
[   14s] FAILED tests/test_circular_imports.py::test_no_warnings[multidict._multidict]
[   14s] FAILED tests/test_circular_imports.py::test_no_warnings[multidict._multidict_base]
[   14s] FAILED tests/test_circular_imports.py::test_no_warnings[multidict._multidict_py]
[   14s] FAILED tests/test_circular_imports.py::test_c_extension_preferred_by_default
[   14s] =================== 7 failed, 905 passed, 2 skipped in 1.64s ===================

Expected behaviour

Testsuite passes

Actual behaviour

See above

Steps to reproduce

Complete build log with all steps taken and record of all packages used.

@webknjaz
Copy link
Member

webknjaz commented Mar 6, 2024

Do you modify PYTHONPATH somehow? The test invokes the same Python where pytest is executed and the imports should work for as long as multidict is also installed there.

@webknjaz
Copy link
Member

webknjaz commented Mar 6, 2024

Ah, the invocations include -I that essentially drop any external PYTHONPATH influence. You have to actually install it where it can be found by the import machinery.

@webknjaz
Copy link
Member

@mcepl have you figured out a workaround for your env? Like installing into the site-packages of the same env as pytest or patching out -I? You could also skip these, I suppose. I'm sure that the upstream checking for circular imports is enough to know that downstream wouldn't have problems it's checking for, unless you start doing weird things to it...

@mcepl
Copy link
Author

mcepl commented Dec 16, 2024

No, I just --ignore tests/test_circular_imports.py. If there is -I in the calling of the Python interpreter, the author just doesn’t work to play with me, and so I won’t be playing with her.

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