From 02be4c53f67e383317605dc91f86536c09c81db8 Mon Sep 17 00:00:00 2001 From: yusyus Date: Sat, 17 Jan 2026 22:02:35 +0300 Subject: [PATCH] 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 --- src/skill_seekers/cli/unified_codebase_analyzer.py | 9 ++++++--- tests/test_architecture_scenarios.py | 4 ++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/skill_seekers/cli/unified_codebase_analyzer.py b/src/skill_seekers/cli/unified_codebase_analyzer.py index 9ea3356..e30cf95 100644 --- a/src/skill_seekers/cli/unified_codebase_analyzer.py +++ b/src/skill_seekers/cli/unified_codebase_analyzer.py @@ -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 diff --git a/tests/test_architecture_scenarios.py b/tests/test_architecture_scenarios.py index 7a3f7e2..02b4264 100644 --- a/tests/test_architecture_scenarios.py +++ b/tests/test_architecture_scenarios.py @@ -202,7 +202,7 @@ How to use async tools. return_value=mock_github_api_data["issues"], ), ): - fetcher = GitHubThreeStreamFetcher("https://github.com/jlowin/fastmcp") + fetcher = GitHubThreeStreamFetcher("https://github.com/jlowin/fastmcp", interactive=False) three_streams = fetcher.fetch() # Verify 3 streams exist @@ -268,7 +268,7 @@ How to use async tools. analyzer = UnifiedCodebaseAnalyzer() result = analyzer.analyze( - source="https://github.com/jlowin/fastmcp", depth="c3x", fetch_github_metadata=True + source="https://github.com/jlowin/fastmcp", depth="c3x", fetch_github_metadata=True, interactive=False ) # Verify result structure