Files
errorfix-cli/tests/conftest.py
2026-02-01 03:56:31 +00:00

58 lines
1.4 KiB
Python

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<message>.*)"
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<name>[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,
},
]