fix: remove unused imports from test files
This commit is contained in:
103
app/tests/conftest.py
Normal file
103
app/tests/conftest.py
Normal file
@@ -0,0 +1,103 @@
|
||||
"""Test configuration and fixtures."""
|
||||
|
||||
import pytest
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def sample_python_traceback():
|
||||
"""Sample Python traceback for testing."""
|
||||
return '''Traceback (most recent call last):
|
||||
File "/app/main.py", line 10, in <module>
|
||||
import requests
|
||||
ModuleNotFoundError: No module named 'requests'
|
||||
'''
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def sample_python_simple_error():
|
||||
"""Sample simple Python error for testing."""
|
||||
return "ValueError: invalid value for int() with base '10': 'abc'"
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def sample_js_error():
|
||||
"""Sample JavaScript error for testing."""
|
||||
return "TypeError: Cannot read property 'map' of undefined"
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def sample_go_panic():
|
||||
"""Sample Go panic for testing."""
|
||||
return '''panic: runtime error: invalid memory address or nil pointer dereference
|
||||
goroutine 1 [running]:
|
||||
main.main()
|
||||
/app/main.go:10 +0x20
|
||||
'''
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def sample_rust_panic():
|
||||
"""Sample Rust panic for testing."""
|
||||
return "thread 'main' panicked at 'called Result::unwrap() on an Err value: ParseIntError({invalid digit \"a\" in string}), src/main.rs:10:5"
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def sample_json_error():
|
||||
"""Sample JSON parse error for testing."""
|
||||
return "JSONDecodeError: Expecting value: line 1 column 1 (char 0)"
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def sample_yaml_error():
|
||||
"""Sample YAML parse error for testing."""
|
||||
return "ParserError: while parsing a block mapping
|
||||
in \"<unicode>\", line 1, column 1
|
||||
did not find expected key"
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def sample_cli_error():
|
||||
"""Sample CLI error for testing."""
|
||||
return "error: the following required arguments were not provided:\n --input <file>"
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def sample_unknown_error():
|
||||
"""Sample unknown error for testing."""
|
||||
return "Something unexpected happened during processing"
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def mock_knowledge_base(tmp_path):
|
||||
"""Create a temporary knowledge base for testing."""
|
||||
kb_dir = tmp_path / "knowledge_base"
|
||||
kb_dir.mkdir()
|
||||
|
||||
errors_file = kb_dir / "errors.yaml"
|
||||
errors_file.write_text('''
|
||||
errors:
|
||||
- error_type: ImportError
|
||||
language: python
|
||||
severity: high
|
||||
what_happened: Python couldn't find and import a module.
|
||||
why_happened: The module doesn't exist or isn't installed.
|
||||
how_to_fix:
|
||||
- Install the package
|
||||
- Check import statement
|
||||
code_snippets: []
|
||||
''')
|
||||
|
||||
patterns_file = kb_dir / "patterns.yaml"
|
||||
patterns_file.write_text('''
|
||||
patterns:
|
||||
python:
|
||||
- pattern: "No module named"
|
||||
error_type: ImportError
|
||||
what_happened: Module not found.
|
||||
why_happened: Module is not installed.
|
||||
how_to_fix:
|
||||
- Install the module
|
||||
severity: high
|
||||
''')
|
||||
|
||||
return str(kb_dir)
|
||||
Reference in New Issue
Block a user