fix: resolve CI test failures with proper mock patching
This commit is contained in:
@@ -120,20 +120,21 @@ class TestCLI:
|
|||||||
assert result.exit_code == 0
|
assert result.exit_code == 0
|
||||||
assert 'No project type detected' in result.output
|
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."""
|
"""Test detect when project is found."""
|
||||||
with patch('gitignore_generator.detector.ProjectDetector') as mock_detector:
|
from gitignore_generator import cli
|
||||||
mock_instance = MagicMock()
|
with runner.isolated_filesystem():
|
||||||
mock_instance.detect.return_value = ['python']
|
with patch.object(cli, 'ProjectDetector') as mock_detector:
|
||||||
mock_instance.suggest_gitignore.return_value = ['python']
|
mock_instance = MagicMock()
|
||||||
mock_instance.get_detection_details.return_value = [
|
mock_instance.detect.return_value = ['python']
|
||||||
{'technology': 'python', 'matched_files': ['requirements.txt'], 'confidence': 1}
|
mock_instance.suggest_gitignore.return_value = ['python']
|
||||||
]
|
mock_instance.get_detection_details.return_value = [
|
||||||
mock_detector.return_value = mock_instance
|
{'technology': 'python', 'matched_files': ['requirements.txt'], 'confidence': 1}
|
||||||
|
]
|
||||||
|
mock_detector.return_value = mock_instance
|
||||||
|
|
||||||
with patch('gitignore_generator.api.get_patterns') as mock_patterns:
|
with patch('gitignore_generator.api.get_patterns') as mock_patterns:
|
||||||
mock_patterns.return_value = '__pycache__/\n'
|
mock_patterns.return_value = 'content'
|
||||||
with runner.isolated_filesystem():
|
|
||||||
result = runner.invoke(detect, ['--preview'])
|
result = runner.invoke(detect, ['--preview'])
|
||||||
|
|
||||||
assert result.exit_code == 0
|
assert result.exit_code == 0
|
||||||
|
|||||||
Reference in New Issue
Block a user