fix: Add interactive parameter to prevent stdin read during tests

Fixes 2 failing tests in test_architecture_scenarios.py that were trying to
read from stdin during pytest execution, causing:
  OSError: pytest: reading from stdin while output is captured!

Changes:
- Added 'interactive' parameter to UnifiedCodebaseAnalyzer.analyze() (defaults to True)
- Pass interactive flag through to _analyze_github() and GitHubThreeStreamFetcher
- Updated failing tests to pass interactive=False

Tests fixed:
- test_scenario_1_github_three_stream_fetcher
- test_scenario_1_unified_analyzer_github

The interactive parameter controls whether the code prompts the user for
input (e.g., 'Continue without token?'). Setting it to False prevents
input() calls, making the code safe for CI/CD and test environments.

All 1386 tests now pass.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
yusyus
2026-01-17 22:02:35 +03:00
parent b837244e42
commit 02be4c53f6
2 changed files with 8 additions and 5 deletions

View File

@@ -74,6 +74,7 @@ class UnifiedCodebaseAnalyzer:
depth: str = "c3x",
fetch_github_metadata: bool = True,
output_dir: Path | None = None,
interactive: bool = True,
) -> AnalysisResult:
"""
Analyze codebase with specified depth.
@@ -83,6 +84,7 @@ class UnifiedCodebaseAnalyzer:
depth: 'basic' or 'c3x'
fetch_github_metadata: Whether to fetch GitHub insights (only for GitHub sources)
output_dir: Directory for temporary files (GitHub clones)
interactive: Whether to show interactive prompts (False for CI/CD and tests)
Returns:
AnalysisResult with all available streams
@@ -93,13 +95,13 @@ class UnifiedCodebaseAnalyzer:
# Step 1: Acquire source
if self.is_github_url(source):
print("📦 Source type: GitHub repository")
return self._analyze_github(source, depth, fetch_github_metadata, output_dir)
return self._analyze_github(source, depth, fetch_github_metadata, output_dir, interactive)
else:
print("📁 Source type: Local directory")
return self._analyze_local(source, depth)
def _analyze_github(
self, repo_url: str, depth: str, fetch_metadata: bool, output_dir: Path | None
self, repo_url: str, depth: str, fetch_metadata: bool, output_dir: Path | None, interactive: bool = True
) -> AnalysisResult:
"""
Analyze GitHub repository with three-stream fetcher.
@@ -109,12 +111,13 @@ class UnifiedCodebaseAnalyzer:
depth: Analysis depth mode
fetch_metadata: Whether to fetch GitHub metadata
output_dir: Output directory for clone
interactive: Whether to show interactive prompts (False for CI/CD and tests)
Returns:
AnalysisResult with all 3 streams
"""
# Use three-stream fetcher
fetcher = GitHubThreeStreamFetcher(repo_url, self.github_token)
fetcher = GitHubThreeStreamFetcher(repo_url, self.github_token, interactive=interactive)
three_streams = fetcher.fetch(output_dir)
# Analyze code with specified depth