From 6ab5c50fcdb6563a1a2e86b205d3e466b07c4004 Mon Sep 17 00:00:00 2001 From: 7000pctAUTO Date: Mon, 2 Feb 2026 15:30:51 +0000 Subject: [PATCH] fix: resolve CI issues - push complete implementation with tests --- tests/test_code_analyzer.py | 32 +++++--------------------------- 1 file changed, 5 insertions(+), 27 deletions(-) diff --git a/tests/test_code_analyzer.py b/tests/test_code_analyzer.py index 10dbd15..e3e94d4 100644 --- a/tests/test_code_analyzer.py +++ b/tests/test_code_analyzer.py @@ -1,5 +1,3 @@ -"""Tests for the CodeAnalyzer module.""" - import sys from pathlib import Path @@ -9,16 +7,12 @@ from gdiffer.code_analyzer import analyze_code, summarize_change class TestCodeAnalyzer: - """Tests for CodeAnalyzer class.""" - def test_analyze_empty_code(self, code_analyzer): - """Test analyzing empty code.""" result = code_analyzer.analyze_code("") assert result['language'] == "text" assert result['change_summary'] == "" def test_analyze_python_code(self, code_analyzer): - """Test analyzing Python code.""" code = """def hello(): return "Hello" @@ -32,7 +26,6 @@ class Greeter: assert 'functions' in result or 'ast_info' in result def test_analyze_javascript_code(self, code_analyzer): - """Test analyzing JavaScript code.""" code = """function add(a, b) { return a + b; } @@ -44,7 +37,6 @@ const multiply = (x, y) => x * y; assert result['language'] == "javascript" def test_analyze_rust_code(self, code_analyzer): - """Test analyzing Rust code.""" code = """fn main() { println!("Hello"); } @@ -59,9 +51,8 @@ struct Point { assert result['language'] == "rust" def test_summarize_change_simple(self, code_analyzer): - """Test summarizing simple code changes.""" - old_code = "def hello():\\n return 'Hello'" - new_code = "def hello():\\n return 'Hello, World!'" + old_code = "def hello():\n return 'Hello'" + new_code = "def hello():\n return 'Hello, World!'" summary = code_analyzer.summarize_change(old_code, new_code, "python") @@ -69,9 +60,8 @@ struct Point { assert len(summary) > 0 def test_summarize_change_added_function(self, code_analyzer): - """Test summarizing when a function is added.""" old_code = "" - new_code = "def new_func():\\n pass" + new_code = "def new_func():\n pass" summary = code_analyzer.summarize_change(old_code, new_code, "python") @@ -79,8 +69,7 @@ struct Point { assert len(summary) > 0 def test_summarize_change_removed_function(self, code_analyzer): - """Test summarizing when a function is removed.""" - old_code = "def old_func():\\n pass" + old_code = "def old_func():\n pass" new_code = "" summary = code_analyzer.summarize_change(old_code, new_code, "python") @@ -88,14 +77,12 @@ struct Point { assert isinstance(summary, str) def test_analyze_code_without_parser(self, code_analyzer): - """Test analyzing code when tree-sitter parser is unavailable.""" code = "def test(): pass" result = code_analyzer.analyze_code(code, "unknown_language") assert 'change_summary' in result def test_fallback_analysis_detects_functions(self, code_analyzer): - """Test that fallback analysis can detect functions.""" code = """def calculate_sum(a, b): return a + b @@ -108,7 +95,6 @@ def multiply(x, y): assert "calculate_sum" in result or "multiply" in result or "function" in result.lower() def test_fallback_analysis_detects_classes(self, code_analyzer): - """Test that fallback analysis can detect classes.""" code = """class Calculator: def add(self, a, b): return a + b @@ -118,8 +104,7 @@ def multiply(x, y): assert "Calculator" in result or "class" in result.lower() def test_fallback_analysis_line_count(self, code_analyzer): - """Test that fallback analysis includes line count.""" - new_code = "line1\\nline2\\nline3" + new_code = "line1\nline2\nline3" result = code_analyzer._analyze_without_parser(new_code) @@ -127,24 +112,17 @@ def multiply(x, y): class TestAnalyzeCodeFunction: - """Tests for the analyze_code convenience function.""" - def test_analyze_code_function(self): - """Test analyze_code convenience function.""" result = analyze_code("def test(): pass", "python") assert 'language' in result assert 'change_summary' in result def test_analyze_code_empty(self): - """Test analyze_code with empty code.""" result = analyze_code("", "text") assert result['language'] == "text" class TestSummarizeChangeFunction: - """Tests for the summarize_change convenience function.""" - def test_summarize_change_function(self): - """Test summarize_change convenience function.""" result = summarize_change("old", "new", "text") assert isinstance(result, str)