- Fixed undefined 'tool' variable in display_history function - Changed '[tool]' markup tag usage to proper Rich syntax - All tests now pass (38/38 unit tests) - Type checking passes with mypy --strict
86 lines
1.7 KiB
Python
86 lines
1.7 KiB
Python
from pathlib import Path
|
|
|
|
import pytest
|
|
|
|
|
|
@pytest.fixture
|
|
def sample_python_code() -> str:
|
|
return '''
|
|
"""Sample Python module for testing."""
|
|
|
|
def function_with_docstring():
|
|
"""This function has a docstring."""
|
|
pass
|
|
|
|
def function_without_docstring():
|
|
pass
|
|
|
|
class SampleClass:
|
|
"""A sample class for testing."""
|
|
|
|
def __init__(self):
|
|
self.value = 42
|
|
|
|
def get_value(self):
|
|
"""Get the stored value."""
|
|
return self.value
|
|
|
|
async def async_function(x: int) -> str:
|
|
"""An async function with type hints."""
|
|
return str(x)
|
|
|
|
@decorator
|
|
def decorated_function():
|
|
pass
|
|
'''
|
|
|
|
@pytest.fixture
|
|
def sample_javascript_code() -> str:
|
|
return '''
|
|
// Sample JavaScript for testing
|
|
function regularFunction(param1, param2) {
|
|
return param1 + param2;
|
|
}
|
|
|
|
const arrowFunction = (x) => x * 2;
|
|
|
|
class SampleClass {
|
|
constructor(name) {
|
|
this.name = name;
|
|
}
|
|
|
|
getName() {
|
|
return this.name;
|
|
}
|
|
}
|
|
|
|
module.exports = { regularFunction, SampleClass };
|
|
'''
|
|
|
|
@pytest.fixture
|
|
def sample_go_code() -> str:
|
|
return '''package main
|
|
|
|
import "fmt"
|
|
|
|
func main() {
|
|
fmt.Println("Hello, World!")
|
|
}
|
|
|
|
func add(a, b int) int {
|
|
return a + b
|
|
}
|
|
'''
|
|
|
|
@pytest.fixture
|
|
def temp_project_dir(tmp_path) -> Path:
|
|
(tmp_path / "src").mkdir()
|
|
(tmp_path / "tests").mkdir()
|
|
(tmp_path / "main.py").write_text("def main(): pass")
|
|
(tmp_path / "src" / "module.py").write_text("def helper(): pass")
|
|
(tmp_path / "tests" / "test_main.py").write_text("def test_main(): pass")
|
|
(tmp_path / ".gitignore").write_text("*.pyc")
|
|
(tmp_path / "__pycache__").mkdir()
|
|
(tmp_path / "__pycache__" / "cache.pyc").write_text("cached")
|
|
return tmp_path
|