fix: resolve CI test failures with proper mock patching
This commit is contained in:
@@ -120,9 +120,11 @@ 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:
|
||||
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']
|
||||
@@ -132,8 +134,7 @@ class TestCLI:
|
||||
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():
|
||||
mock_patterns.return_value = 'content'
|
||||
result = runner.invoke(detect, ['--preview'])
|
||||
|
||||
assert result.exit_code == 0
|
||||
|
||||
Reference in New Issue
Block a user