Skip to content

Commit 045f914

Browse files
committed
display during test discovery too
1 parent 3f6547d commit 045f914

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

codeflash/discovery/discover_unit_tests.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,16 @@
1414

1515
import pytest
1616
from pydantic.dataclasses import dataclass
17+
from rich.panel import Panel
18+
from rich.text import Text
1719

1820
from codeflash.cli_cmds.console import console, logger, test_files_progress_bar
19-
from codeflash.code_utils.code_utils import custom_addopts, get_run_tmp_file, module_name_from_file_path
21+
from codeflash.code_utils.code_utils import (
22+
ImportErrorPattern,
23+
custom_addopts,
24+
get_run_tmp_file,
25+
module_name_from_file_path,
26+
)
2027
from codeflash.code_utils.compat import SAFE_SYS_EXECUTABLE, codeflash_cache_db
2128
from codeflash.models.models import CodePosition, FunctionCalledInTest, TestsInFile, TestType
2229

@@ -180,6 +187,10 @@ def discover_tests_pytest(
180187
logger.warning(
181188
f"Failed to collect tests. Pytest Exit code: {exitcode}={pytest.ExitCode(exitcode).name}\n {error_section}"
182189
)
190+
if "ModuleNotFoundError" in result.stdout:
191+
match = ImportErrorPattern.search(result.stdout).group()
192+
panel = Panel(Text.from_markup(f"⚠️ {match} ", style="bold red"), expand=False)
193+
console.print(panel)
183194

184195
elif 0 <= exitcode <= 5:
185196
logger.warning(f"Failed to collect tests. Pytest Exit code: {exitcode}={pytest.ExitCode(exitcode).name}")

0 commit comments

Comments
 (0)