Skip to content

Commit 951a12d

Browse files
log the warn message during configuration
1 parent fcc30b7 commit 951a12d

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

codeflash/cli_cmds/cmd_init.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,6 @@ def init_codeflash() -> None:
7272

7373
if should_modify_pyproject_toml():
7474
setup_info: SetupInfo = collect_setup_info()
75-
if Path(setup_info.module_root).resolve() == Path(setup_info.tests_root).resolve():
76-
logger.warning(
77-
"It looks like your tests root is the same as your module root. This is not recommended and can lead to unexpected behavior."
78-
)
7975
configure_pyproject_toml(setup_info)
8076

8177
install_github_app()
@@ -214,7 +210,7 @@ def collect_setup_info() -> SetupInfo:
214210
# Discover test directory
215211
default_tests_subdir = "tests"
216212
create_for_me_option = f"okay, create a tests{os.pathsep} directory for me!"
217-
test_subdir_options = valid_subdirs
213+
test_subdir_options = [sub_dir for sub_dir in valid_subdirs if sub_dir != module_root]
218214
if "tests" not in valid_subdirs:
219215
test_subdir_options.append(create_for_me_option)
220216
custom_dir_option = "enter a custom directory…"
@@ -243,7 +239,14 @@ def collect_setup_info() -> SetupInfo:
243239
apologize_and_exit()
244240
else:
245241
tests_root = Path(curdir) / Path(cast("str", tests_root_answer))
246-
tests_root = tests_root.relative_to(curdir)
242+
243+
resolved_module_root = (Path(curdir) / Path(module_root)).resolve()
244+
resolved_tests_root = (Path(curdir) / Path(module_root)).resolve()
245+
if resolved_module_root == resolved_tests_root:
246+
logger.warning(
247+
"It looks like your tests root is the same as your module root. This is not recommended and can lead to unexpected behavior."
248+
)
249+
247250
ph("cli-tests-root-provided")
248251

249252
# Autodiscover test framework

0 commit comments

Comments
 (0)