Initial upload: ErrorFix CLI with rule engine and pattern matching
Some checks failed
CI / test (push) Has been cancelled
Some checks failed
CI / test (push) Has been cancelled
This commit is contained in:
57
tests/conftest.py
Normal file
57
tests/conftest.py
Normal file
@@ -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<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,
|
||||
},
|
||||
]
|
||||
Reference in New Issue
Block a user