"""Test configuration and fixtures.""" from pathlib import Path import pytest @pytest.fixture def create_python_project(tmp_path: Path) -> Path: """Create a Python project structure for testing.""" src_dir = tmp_path / "src" src_dir.mkdir() (src_dir / "__init__.py").write_text('"""Package init."""') (src_dir / "main.py").write_text('"""Main module.""" def hello(): """Say hello.""" print("Hello, World!") class Calculator: """A simple calculator.""" def add(self, a: int, b: int) -> int: """Add two numbers.""" return a + b def multiply(self, a: int, b: int) -> int: """Multiply two numbers.""" return a * b ') (tmp_path / "requirements.txt").write_text('requests>=2.31.0 click>=8.0.0 pytest>=7.0.0 ') (tmp_path / "pyproject.toml").write_text('[build-system] requires = ["setuptools"] build-backend = "setuptools.build_meta" [project] name = "test-project" version = "0.1.0" description = "A test project" requires-python = ">=3.9" dependencies = [ "requests>=2.31.0", "click>=8.0.0", ] ') return tmp_path @pytest.fixture def create_javascript_project(tmp_path: Path) -> Path: """Create a JavaScript project structure for testing.""" (tmp_path / "package.json").write_text('{ "name": "test-js-project", "version": "1.0.0", "description": "A test JavaScript project", "main": "index.js", "dependencies": { "express": "^4.18.0", "lodash": "^4.17.0" }, "devDependencies": { "jest": "^29.0.0" } } ') (tmp_path / "index.js").write_text('const express = require(\'express\'); const _ = require(\'lodash\'); function hello() { return \'Hello, World!\'; } class Calculator { add(a, b) { return a + b; } } module.exports = { hello, Calculator }; ') return tmp_path @pytest.fixture def create_go_project(tmp_path: Path) -> Path: """Create a Go project structure for testing.""" (tmp_path / "go.mod").write_text('module test-go-project go 1.21 require ( github.com/gin-gonic/gin v1.9.0 github.com/stretchr/testify v1.8.0 ) ') (tmp_path / "main.go").write_text('package main import "fmt" func hello() string { return "Hello, World!" } type Calculator struct{} func (c *Calculator) Add(a, b int) int { return a + b } func main() { fmt.Println(hello()) } ') return tmp_path @pytest.fixture def create_rust_project(tmp_path: Path) -> Path: """Create a Rust project structure for testing.""" src_dir = tmp_path / "src" src_dir.mkdir() (tmp_path / "Cargo.toml").write_text('[package] name = "test-rust-project" version = "0.1.0" edition = "2021" [dependencies] serde = { version = "1.0", features = ["derive"] } tokio = { version = "1.0", features = "full" } [dev-dependencies] assertions = "0.1" ') (src_dir / "main.rs").write_text('fn hello() -> String { "Hello, World!".to_string() } pub struct Calculator; impl Calculator { pub fn add(a: i32, b: i32) -> i32 { a + b } } fn main() { println!("{}", hello()); } ') return tmp_path @pytest.fixture def create_mixed_project(tmp_path: Path) -> Path: """Create a project with multiple languages for testing.""" python_part = tmp_path / "python_part" python_part.mkdir() js_part = tmp_path / "js_part" js_part.mkdir() src_dir = python_part / "src" src_dir.mkdir() (src_dir / "__init__.py").write_text('"""Package init."""') (src_dir / "main.py").write_text('"""Main module.""" def hello(): print("Hello") ') (python_part / "pyproject.toml").write_text('[project] name = "test-project" version = "0.1.0" description = "A test project" requires-python = ">=3.9" dependencies = ["requests>=2.31.0"] ') (js_part / "package.json").write_text('{ "name": "test-js-project", "version": "1.0.0", "description": "A test project" } ') (js_part / "index.js").write_text('function hello() { return \'Hello\'; } module.exports = { hello }; ') return tmp_path