question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

7.1.0 - ImportError with pytest-cases

See original GitHub issue

Hi team,

  • trying to run a test suite (FastAPI) in a container RUN pip3 install --no-cache-dir responses pytest-7.0.1 pytest-asyncio pytest_cases pytest-cov httpx asgi-lifespan starlette ENTRYPOINT ["pytest","-vv","--cov=.","tests"]

  • things are working fine in 7.0.1

  • execution is failing in 7.1.0

Traceback (most recent call last):
  File "[/usr/local/lib/python3.10/runpy.py]()", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "[/usr/local/lib/python3.10/runpy.py]()", line 86, in _run_code
    exec(code, run_globals)
  File "[/usr/local/lib/python3.10/site-packages/debugpy/__main__.py]()", line 45, in <module>
    cli.main()
  File "[/usr/local/lib/python3.10/site-packages/debugpy/server/cli.py]()", line 444, in main
    run()
  File "[/usr/local/lib/python3.10/site-packages/debugpy/server/cli.py]()", line 331, in run_module
    run_module_as_main(target_as_str, alter_argv=True)
  File "[/usr/local/lib/python3.10/runpy.py]()", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "[/usr/local/lib/python3.10/runpy.py]()", line 86, in _run_code
    exec(code, run_globals)
  File "[/usr/local/lib/python3.10/site-packages/pytest/__main__.py]()", line 5, in <module>
    raise SystemExit(pytest.console_main())
  File "[/usr/local/lib/python3.10/site-packages/_pytest/config/__init__.py]()", line 187, in console_main
    code = main()
  File "[/usr/local/lib/python3.10/site-packages/_pytest/config/__init__.py]()", line 145, in main
    config = _prepareconfig(args, plugins)
  File "[/usr/local/lib/python3.10/site-packages/_pytest/config/__init__.py]()", line 324, in _prepareconfig
    config = pluginmanager.hook.pytest_cmdline_parse(
  File "[/usr/local/lib/python3.10/site-packages/pluggy/_hooks.py]()", line 265, in __call__
    return self._hookexec(self.name, self.get_hookimpls(), kwargs, firstresult)
  File "[/usr/local/lib/python3.10/site-packages/pluggy/_manager.py]()", line 80, in _hookexec
    return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
  File "[/usr/local/lib/python3.10/site-packages/pluggy/_callers.py]()", line 55, in _multicall
    gen.send(outcome)
  File "[/usr/local/lib/python3.10/site-packages/_pytest/helpconfig.py]()", line 102, in pytest_cmdline_parse
    config: Config = outcome.get_result()
  File "[/usr/local/lib/python3.10/site-packages/pluggy/_result.py]()", line 60, in get_result
    raise ex[1].with_traceback(ex[2])
  File "[/usr/local/lib/python3.10/site-packages/pluggy/_callers.py]()", line 39, in _multicall
    res = hook_impl.function(*args)
  File "[/usr/local/lib/python3.10/site-packages/_pytest/config/__init__.py]()", line 1020, in pytest_cmdline_parse
    self.parse(args)
  File "[/usr/local/lib/python3.10/site-packages/_pytest/config/__init__.py]()", line 1308, in parse
    self._preparse(args, addopts=addopts)
  File "[/usr/local/lib/python3.10/site-packages/_pytest/config/__init__.py]()", line 1191, in _preparse
    self.pluginmanager.load_setuptools_entrypoints("pytest11")
  File "[/usr/local/lib/python3.10/site-packages/pluggy/_manager.py]()", line 287, in load_setuptools_entrypoints
    plugin = ep.load()
  File "[/usr/local/lib/python3.10/importlib/metadata/__init__.py]()", line 162, in load
    module = import_module(match.group('module'))
  File "[/usr/local/lib/python3.10/importlib/__init__.py]()", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
  File "<frozen importlib._bootstrap>", line 992, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 241, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1050, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1027, in _find_and_load
 File "<frozen importlib._bootstrap>", line 1006, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 688, in _load_unlocked
  File "[/usr/local/lib/python3.10/site-packages/_pytest/assertion/rewrite.py]()", line 168, in exec_module
    exec(co, module.__dict__)
  File "[/usr/local/lib/python3.10/site-packages/pytest_cases/__init__.py]()", line 8, in <module>
    from .fixture_core1_unions import fixture_union, NOT_USED, unpack_fixture, ignore_unused
  File "[/usr/local/lib/python3.10/site-packages/_pytest/assertion/rewrite.py]()", line 168, in exec_module
    exec(co, module.__dict__)
  File "[/usr/local/lib/python3.10/site-packages/pytest_cases/fixture_core1_unions.py]()", line 26, in <module>
    from .common_pytest import get_fixture_name, is_marked_parameter_value, get_marked_parameter_values, pytest_fixture, \
  File "[/usr/local/lib/python3.10/site-packages/_pytest/assertion/rewrite.py]()", line 168, in exec_module
    exec(co, module.__dict__)
  File "[/usr/local/lib/python3.10/site-packages/pytest_cases/common_pytest.py]()", line 557, in <module>
    from _pytest.python import _idval  # noqa
ImportError: cannot import name '_idval' from '_pytest.python' ([/usr/local/lib/python3.10/site-packages/_pytest/python.py]())

Thanks!!


(Edited by @The-Compiler to use triple-backticks for a more readable log)

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
The-Compilercommented, Mar 14, 2022

Thanks @smarie for the quick fix!

0reactions
smariecommented, Mar 14, 2022

Fixed in pytest-cases 3.6.10. Thanks for reporting !

Read more comments on GitHub >

github_iconTop Results From Across the Web

Changelog - pytest_cases
Fixed ImportError when using pytest 7.1 . ... dirty hack used by pytest-cases to trick pytest to generate acceptable test ids in these...
Read more >
How to solve ImportError with pytest - python - Stack Overflow
First of all, from testingonly import Tester is wrong. The Tester class is defined in module with qualname testingonly.testingonly as is not ...
Read more >
pytest Documentation - Read the Docs
pytest-cases last release: May 20, ... An encrypted password store for use within pytest cases pytest-select ... Ignore doctest ImportErrors.
Read more >
Changelog — pytest documentation
#9767: Fixed a regression in pytest 7.1.0 where some conftest.py files outside of ... (for example an ImportError while importing a specific warning...
Read more >
Change Logs — PyArmor 7.6.0 documentation
Change spp build library version to r3; Fix bug: ImportError: dynamic module does ... 7.1.0¶. Check the conflicts of option --restrict 0 and...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found