diff --git a/tests/fixtures/sample_code.py b/tests/fixtures/sample_code.py new file mode 100644 index 0000000..b43dc0f --- /dev/null +++ b/tests/fixtures/sample_code.py @@ -0,0 +1,88 @@ +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