diff --git a/tests/conftest.py b/tests/conftest.py new file mode 100644 index 0000000..e498f80 --- /dev/null +++ b/tests/conftest.py @@ -0,0 +1,125 @@ +"""Pytest configuration and fixtures for i18n-guardian tests.""" + +import tempfile +from pathlib import Path + +import pytest + + +@pytest.fixture +def temp_dir(): + """Create a temporary directory for tests.""" + with tempfile.TemporaryDirectory() as tmpdir: + yield Path(tmpdir) + + +@pytest.fixture +def sample_python_file(temp_dir): + """Create a sample Python file with hardcoded strings.""" + content = ''' +def greet(name): + return "Hello, " + name + +def farewell(): + return "Goodbye, world!" + +message = "This is a test message" +url = "https://example.com" +email = "test@example.com" +regex = r"^pattern$" +''' + file_path = temp_dir / "test.py" + file_path.write_text(content, encoding="utf-8") + return file_path + + +@pytest.fixture +def sample_js_file(temp_dir): + """Create a sample JavaScript file with hardcoded strings.""" + content = ''' +function greet(name) { + return "Hello, " + name; +} + +function farewell() { + return "Goodbye, world!"; +} + +const message = "This is a test message"; +const url = "https://example.com"; +const email = "test@example.com"; +''' + file_path = temp_dir / "test.js" + file_path.write_text(content, encoding="utf-8") + return file_path + + +@pytest.fixture +def sample_tsx_file(temp_dir): + """Create a sample TypeScript React file.""" + content = ''' +import React from 'react'; + +export function Welcome() { + return ( +
This is a translated message
+