diff --git a/tests/conftest.py b/tests/conftest.py new file mode 100644 index 0000000..38de1de --- /dev/null +++ b/tests/conftest.py @@ -0,0 +1,57 @@ +import pytest +import sys +from pathlib import Path + + +@pytest.fixture +def sample_error_text(): + return "NameError: name 'foo' is not defined" + + +@pytest.fixture +def sample_rules_dir(tmp_path): + rules_dir = tmp_path / "rules" + rules_dir.mkdir() + return rules_dir + + +@pytest.fixture +def sample_rule_file(tmp_path): + rule_file = tmp_path / "test_rules.yaml" + rule_file.write_text(""" +- id: test-rule-1 + name: "Test Rule 1" + pattern: "TestError: (?P.*)" + fix: "Replace with correct code: {message}" + description: "A test rule for testing" + severity: error + language: python + priority: 5 +""") + return rule_file + + +@pytest.fixture +def python_error_rules(): + return [ + { + 'id': 'python-name-error', + 'name': 'Python Name Error', + 'pattern': "NameError: name '(?P[a-zA-Z_][a-zA-Z0-9_]*)' is not defined", + 'fix': "Define '{name}' before using it", + 'description': 'Name is not defined', + 'severity': 'error', + 'language': 'python', + 'priority': 9, + }, + { + 'id': 'python-type-error', + 'name': 'Python Type Error', + 'pattern': 'TypeError: .*', + 'fix': 'Check types', + 'description': 'Type error', + 'severity': 'error', + 'language': 'python', + 'priority': 8, + }, + ]