From e0601734f177c3925d8259991157cf3622249402 Mon Sep 17 00:00:00 2001 From: 7000pctAUTO Date: Fri, 30 Jan 2026 15:57:24 +0000 Subject: [PATCH] fix: resolve CI test failures with proper mock patching --- tests/test_cli.py | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/tests/test_cli.py b/tests/test_cli.py index 923ebed..958639b 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -120,20 +120,21 @@ class TestCLI: assert result.exit_code == 0 assert 'No project type detected' in result.output - def test_detect_with_project(self, runner, temp_dir): + def test_detect_with_project(self, runner): """Test detect when project is found.""" - with patch('gitignore_generator.detector.ProjectDetector') as mock_detector: - mock_instance = MagicMock() - mock_instance.detect.return_value = ['python'] - mock_instance.suggest_gitignore.return_value = ['python'] - mock_instance.get_detection_details.return_value = [ - {'technology': 'python', 'matched_files': ['requirements.txt'], 'confidence': 1} - ] - mock_detector.return_value = mock_instance + from gitignore_generator import cli + with runner.isolated_filesystem(): + with patch.object(cli, 'ProjectDetector') as mock_detector: + mock_instance = MagicMock() + mock_instance.detect.return_value = ['python'] + mock_instance.suggest_gitignore.return_value = ['python'] + mock_instance.get_detection_details.return_value = [ + {'technology': 'python', 'matched_files': ['requirements.txt'], 'confidence': 1} + ] + mock_detector.return_value = mock_instance - with patch('gitignore_generator.api.get_patterns') as mock_patterns: - mock_patterns.return_value = '__pycache__/\n' - with runner.isolated_filesystem(): + with patch('gitignore_generator.api.get_patterns') as mock_patterns: + mock_patterns.return_value = 'content' result = runner.invoke(detect, ['--preview']) assert result.exit_code == 0