Running pytest with "debug in test" works correctly but "run in test" fails.
I have a project where I am running tests using the debug menu pull down and they run fine.
============================= test session starts =============================
platform win32 -- Python 3.8.0, pytest-6.0.1, py-1.9.0, pluggy-0.13.1 -- C:\Users\cbass\venv\pcs_sputter\Scripts\python.exe
cachedir: .pytest_cache
rootdir: C:\Users\cbass\source\repos\pcs_sputter
collecting ... collected 12 items
..\..\test\test.py::test_timestamp_read_write_io
..\..\test\test.py::test_read_sputter_pvd_file
..\..\test\test.py::test_read_sputter_pvd_file_bad
..\..\test\test.py::test_sputter_file_dataclass_good
..\..\test\test.py::test_sputter_file_dataclass_bad
..\..\test\test.py::test_recognizer_valid
..\..\test\test.py::test_recognizer_bad_extensions
..\..\test\test.py::test_recognizer_bad_filenames
..\..\test\test.py::test_parse_time
..\..\test\test.py::test_file_in_time_window
..\..\test\test.py::test_check_time_in_window
..\..\test\test.py::test_get_run_value_from_desc
When I do "run pytest in test" I get errors. It can't find the imports correctly as can be seen by "No Module Named sputter" error message. Don't debug and run use the same run configuration? I don't see anywhere where I can run/debug separately. What configuration in PyCharm controls the difference between run/debug?
=================================== ERRORS ====================================
________________________ ERROR collecting test/test.py ________________________
ImportError while importing test module 'C:\Users\cbass\source\repos\pcs_sputter\test\test.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
C:\Users\cbass\venv\pcs_sputter\lib\site-packages\_pytest\python.py:552: in _importtestmodule
mod = import_path(self.fspath, mode=importmode)
C:\Users\cbass\venv\pcs_sputter\lib\site-packages\_pytest\pathlib.py:520: in import_path
importlib.import_module(module_name)
C:\Users\cbass\AppData\Local\Programs\Python\Python38\lib\importlib\__init__.py:127: in import_module
return _bootstrap._gcd_import(name[level:], package, level)
<frozen importlib._bootstrap>:1014: in _gcd_import
???
<frozen importlib._bootstrap>:991: in _find_and_load
???
<frozen importlib._bootstrap>:975: in _find_and_load_unlocked
???
<frozen importlib._bootstrap>:671: in _load_unlocked
???
C:\Users\cbass\venv\pcs_sputter\lib\site-packages\_pytest\assertion\rewrite.py:170: in exec_module
exec(co, module.__dict__)
..\..\test\test.py:5: in <module>
from sputter import *
E ModuleNotFoundError: No module named 'sputter'
=========================== short test summary info ===========================
ERROR ..\..\test\test.py
!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!
============================== 1 error in 0.19s ===============================
Here is py run configuration:
Please sign in to leave a comment.

After digging in the docs I found this:
This does seem to indicate that the working directory that I set is screwing things up. However, if I go back into my Run/Dbg config and remove the working folder declaration then both the Debug and Run versions fail.
I observe the same problem - PyCharm 2022.1 - is there still no solution or helpful hint for this?
The same thing is happening for me.
DEBUG level fails, but INFO works
I fixed it by turning off ddtrace instrumentation from happening.
I have both ddtrace and opentelemetry in the same library, and enabling ddrace breaks opentelemetry, which then somehow broke DEBUG logging.
This is what ddtrace instrumentation looks like: