88"""
99
1010import json
11- import os
1211from argparse import Namespace
13- from pathlib import Path
14- from unittest .mock import patch
1512
1613import pytest
1714import tomlkit
1815
1916from codeflash .setup import (
2017 CodeflashConfig ,
21- DetectedProject ,
2218 detect_project ,
2319 handle_first_run ,
2420 has_existing_config ,
2521 is_first_run ,
2622 write_config ,
2723)
2824
29-
3025# =============================================================================
3126# Fixtures for creating different project types
3227# =============================================================================
@@ -365,7 +360,7 @@ def test_python_src_layout_detection(self, python_src_layout):
365360
366361 assert detected .language == "python"
367362 assert detected .project_root == python_src_layout
368- assert "myapp" in str ( detected .module_root )
363+ assert detected .module_root . name == "myapp"
369364 assert detected .tests_root == python_src_layout / "tests"
370365 assert detected .test_runner == "pytest"
371366 assert any ("ruff" in cmd for cmd in detected .formatter_cmds )
@@ -376,15 +371,15 @@ def test_python_flat_layout_detection(self, python_flat_layout):
376371 detected = detect_project (python_flat_layout )
377372
378373 assert detected .language == "python"
379- assert "myapp" in str ( detected .module_root )
374+ assert detected .module_root . name == "myapp"
380375 assert any ("black" in cmd for cmd in detected .formatter_cmds )
381376
382377 def test_python_setup_py_detection (self , python_setup_py_project ):
383378 """Should correctly detect legacy setup.py project."""
384379 detected = detect_project (python_setup_py_project )
385380
386381 assert detected .language == "python"
387- assert "legacyapp" in str ( detected .module_root )
382+ assert detected .module_root . name == "legacyapp"
388383
389384 def test_javascript_npm_detection (self , javascript_npm_project ):
390385 """Should correctly detect JavaScript npm project."""
@@ -578,14 +573,14 @@ def test_first_run_python_project(self, python_src_layout, monkeypatch):
578573
579574 assert result is not None
580575 assert result .language == "python"
581- assert "myapp" in result .module_root
576+ assert result .module_root . endswith ( "myapp" )
582577 assert result .tests_root is not None
583- assert "tests" in result .tests_root
578+ assert result .tests_root . endswith ( "tests" )
584579 assert result .pytest_cmd == "pytest"
585580
586581 # Config should be written
587582 content = (python_src_layout / "pyproject.toml" ).read_text ()
588- assert "codeflash" in content
583+ assert "[tool. codeflash] " in content
589584
590585 def test_first_run_javascript_project (self , javascript_npm_project , monkeypatch ):
591586 """Should complete first-run for JavaScript project."""
@@ -596,7 +591,7 @@ def test_first_run_javascript_project(self, javascript_npm_project, monkeypatch)
596591
597592 assert result is not None
598593 assert result .language == "javascript"
599- assert "src" in result .module_root
594+ assert result .module_root . endswith ( "src" )
600595 assert result .pytest_cmd == "jest" # Maps to test_runner
601596
602597 def test_first_run_typescript_project (self , typescript_project , monkeypatch ):
0 commit comments