-
Notifications
You must be signed in to change notification settings - Fork 0
test: autofix system validation with intentional failures #84
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,162 @@ | ||||||
| """Test file with intentional issues to validate autofix system. | ||||||
|
|
||||||
| This file contains: | ||||||
| 1. Black formatting violations | ||||||
| 2. Ruff lint errors | ||||||
| 3. Mypy type errors | ||||||
| 4. Failing tests | ||||||
| 5. Actual useful test coverage | ||||||
|
|
||||||
| Purpose: Validate the full autofix pipeline handles all failure modes. | ||||||
| """ | ||||||
|
|
||||||
| # --- BLACK VIOLATION: Bad formatting --- | ||||||
|
|
||||||
| # --- RUFF VIOLATIONS --- | ||||||
| # F401: unused import | ||||||
| import os | ||||||
|
|
||||||
| from adapters.base import connect_db, get_adapter | ||||||
|
|
||||||
| # E501: line too long | ||||||
| VERY_LONG_STRING_THAT_VIOLATES_LINE_LENGTH = "This is a very long string that definitely exceeds the maximum line length limit of 88 characters that ruff and black enforce by default" | ||||||
|
|
||||||
|
|
||||||
| # --- MYPY TYPE ERROR --- | ||||||
| def bad_type_annotation(x: int) -> str: | ||||||
| return x # Returns int, claims str | ||||||
|
Comment on lines
+26
to
+27
|
||||||
|
|
||||||
|
|
||||||
| def missing_return_type(value): | ||||||
| """Function missing type annotations.""" | ||||||
| return value * 2 | ||||||
|
|
||||||
|
|
||||||
| # --- BLACK VIOLATION: Inconsistent spacing --- | ||||||
| def poorly_formatted_function(arg1, arg2, arg3): | ||||||
| """This function has poor formatting.""" | ||||||
| result = arg1 + arg2 + arg3 | ||||||
| if result > 10: | ||||||
| return result | ||||||
| else: | ||||||
| return result * 2 | ||||||
|
|
||||||
|
|
||||||
| class BadlyFormattedClass: | ||||||
| """Class with formatting issues.""" | ||||||
|
|
||||||
| def __init__(self, name: str, value: int): | ||||||
| self.name = name | ||||||
| self.value = value | ||||||
|
|
||||||
| def compute(self, multiplier: int) -> int: | ||||||
| return self.value * multiplier | ||||||
|
|
||||||
|
|
||||||
| # --- ACTUAL USEFUL COVERAGE TESTS --- | ||||||
|
|
||||||
|
|
||||||
| def test_connect_db_sqlite_default(): | ||||||
| """Test connect_db returns valid SQLite connection.""" | ||||||
| # Clear env vars to force SQLite path | ||||||
| old_url = os.environ.pop("DB_URL", None) | ||||||
| old_path = os.environ.pop("DB_PATH", None) | ||||||
|
Comment on lines
+62
to
+63
|
||||||
|
|
||||||
| try: | ||||||
| conn = connect_db(":memory:") | ||||||
| assert conn is not None | ||||||
| # Verify it's a working connection | ||||||
| cursor = conn.cursor() | ||||||
| cursor.execute("SELECT 1") | ||||||
| result = cursor.fetchone() | ||||||
| assert result == (1,) | ||||||
| conn.close() | ||||||
| finally: | ||||||
| if old_url: | ||||||
| os.environ["DB_URL"] = old_url | ||||||
| if old_path: | ||||||
| os.environ["DB_PATH"] = old_path | ||||||
|
|
||||||
|
|
||||||
| def test_connect_db_with_timeout(): | ||||||
| """Test connect_db accepts timeout parameter.""" | ||||||
| conn = connect_db(":memory:", connect_timeout=5.0) | ||||||
| assert conn is not None | ||||||
| conn.close() | ||||||
|
|
||||||
|
|
||||||
| def test_get_adapter_edgar(): | ||||||
| """Test that edgar adapter can be loaded.""" | ||||||
| try: | ||||||
| adapter = get_adapter("edgar") | ||||||
| assert adapter is not None | ||||||
| # Verify it has expected protocol methods | ||||||
| assert ( | ||||||
| hasattr(adapter, "list_new_filings") | ||||||
| or callable(getattr(adapter, "list_new_filings", None)) is False | ||||||
| ) | ||||||
| except ModuleNotFoundError: | ||||||
| # Adapter module may not exist yet | ||||||
| pass | ||||||
|
|
||||||
|
|
||||||
| def test_get_adapter_invalid(): | ||||||
| """Test get_adapter raises for unknown adapter.""" | ||||||
| try: | ||||||
| get_adapter("nonexistent_adapter_xyz") | ||||||
| assert False, "Should have raised" | ||||||
|
Check failure on line 107 in tests/test_autofix_validation.py
|
||||||
| except (ModuleNotFoundError, ImportError): | ||||||
| pass # Expected | ||||||
|
|
||||||
|
|
||||||
| # --- INTENTIONALLY FAILING TESTS --- | ||||||
|
|
||||||
|
|
||||||
| def test_intentional_failure_assertion(): | ||||||
| """This test intentionally fails with an assertion error.""" | ||||||
| expected = 42 | ||||||
| actual = 41 | ||||||
| assert actual == expected, f"Expected {expected} but got {actual}" | ||||||
|
Comment on lines
+115
to
+119
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The three “intentional failure” tests here all fail unconditionally ( Useful? React with 👍 / 👎.
Comment on lines
+115
to
+119
|
||||||
|
|
||||||
|
|
||||||
| def test_intentional_failure_exception(): | ||||||
| """This test intentionally raises an exception.""" | ||||||
| data = {"key": "value"} | ||||||
| # This will raise KeyError | ||||||
| result = data["nonexistent_key"] | ||||||
|
Check failure on line 126 in tests/test_autofix_validation.py
|
||||||
|
Comment on lines
+122
to
+126
|
||||||
| result = data["nonexistent_key"] | |
| data["nonexistent_key"] |
Check failure on line 133 in tests/test_autofix_validation.py
GitHub Actions / Python CI / lint-ruff
Ruff (F841)
tests/test_autofix_validation.py:133:5: F841 Local variable `result` is assigned to but never used
Check failure on line 133 in tests/test_autofix_validation.py
GitHub Actions / Python CI / lint-ruff
Ruff (F841)
tests/test_autofix_validation.py:133:5: F841 Local variable `result` is assigned to but never used
Check failure on line 133 in tests/test_autofix_validation.py
GitHub Actions / Python CI / lint-ruff
Ruff (F841)
tests/test_autofix_validation.py:133:5: F841 Local variable `result` is assigned to but never used
Check failure on line 133 in tests/test_autofix_validation.py
GitHub Actions / Python CI / lint-ruff
Ruff (F841)
tests/test_autofix_validation.py:133:5: F841 Local variable `result` is assigned to but never used
Check failure on line 133 in tests/test_autofix_validation.py
GitHub Actions / Python CI / lint-ruff
Ruff (F841)
tests/test_autofix_validation.py:133:5: F841 Local variable `result` is assigned to but never used
Check failure on line 133 in tests/test_autofix_validation.py
GitHub Actions / Python CI / lint-ruff
Ruff (F841)
tests/test_autofix_validation.py:133:5: F841 Local variable `result` is assigned to but never used
Check failure on line 133 in tests/test_autofix_validation.py
GitHub Actions / Python CI / lint-ruff
Ruff (F841)
tests/test_autofix_validation.py:133:5: F841 Local variable `result` is assigned to but never used
Copilot
AI
Dec 29, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test intentionally raises a TypeError. Like the other intentionally failing tests, this will cause test suite failures when executed. Consider using pytest skip markers for these validation tests to avoid disrupting normal CI/CD workflows until the autofix system has been properly validated.
Copilot
AI
Dec 29, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Variable result is not used.
| result = value + 5 | |
| value + 5 |
Check failure on line 150 in tests/test_autofix_validation.py
GitHub Actions / Python CI / lint-ruff
Ruff (E711)
tests/test_autofix_validation.py:150:17: E711 Comparison to `None` should be `cond is None`
Check failure on line 150 in tests/test_autofix_validation.py
GitHub Actions / Python CI / lint-ruff
Ruff (E711)
tests/test_autofix_validation.py:150:17: E711 Comparison to `None` should be `cond is None`
Check failure on line 150 in tests/test_autofix_validation.py
GitHub Actions / Python CI / lint-ruff
Ruff (E711)
tests/test_autofix_validation.py:150:17: E711 Comparison to `None` should be `cond is None`
Check failure on line 150 in tests/test_autofix_validation.py
GitHub Actions / Python CI / lint-ruff
Ruff (E711)
tests/test_autofix_validation.py:150:17: E711 Comparison to `None` should be `cond is None`
Check failure on line 150 in tests/test_autofix_validation.py
GitHub Actions / Python CI / lint-ruff
Ruff (E711)
tests/test_autofix_validation.py:150:17: E711 Comparison to `None` should be `cond is None`
Check failure on line 150 in tests/test_autofix_validation.py
GitHub Actions / Python CI / lint-ruff
Ruff (E711)
tests/test_autofix_validation.py:150:17: E711 Comparison to `None` should be `cond is None`
Check failure on line 150 in tests/test_autofix_validation.py
GitHub Actions / Python CI / lint-ruff
Ruff (E711)
tests/test_autofix_validation.py:150:17: E711 Comparison to `None` should be `cond is None`
Copilot
AI
Dec 29, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Testing for None should use the 'is' operator.
| if value == None: | |
| if value is None: |
Check failure on line 157 in tests/test_autofix_validation.py
GitHub Actions / Python CI / lint-ruff
Ruff (E712)
tests/test_autofix_validation.py:157:8: E712 Avoid equality comparisons to `True`; use `flag:` for truth checks
Check failure on line 157 in tests/test_autofix_validation.py
GitHub Actions / Python CI / lint-ruff
Ruff (E712)
tests/test_autofix_validation.py:157:8: E712 Avoid equality comparisons to `True`; use `flag:` for truth checks
Check failure on line 157 in tests/test_autofix_validation.py
GitHub Actions / Python CI / lint-ruff
Ruff (E712)
tests/test_autofix_validation.py:157:8: E712 Avoid equality comparisons to `True`; use `flag:` for truth checks
Check failure on line 157 in tests/test_autofix_validation.py
GitHub Actions / Python CI / lint-ruff
Ruff (E712)
tests/test_autofix_validation.py:157:8: E712 Avoid equality comparisons to `True`; use `flag:` for truth checks
Check failure on line 157 in tests/test_autofix_validation.py
GitHub Actions / Python CI / lint-ruff
Ruff (E712)
tests/test_autofix_validation.py:157:8: E712 Avoid equality comparisons to `True`; use `flag:` for truth checks
Check failure on line 157 in tests/test_autofix_validation.py
GitHub Actions / Python CI / lint-ruff
Ruff (E712)
tests/test_autofix_validation.py:157:8: E712 Avoid equality comparisons to `True`; use `flag:` for truth checks
Check failure on line 157 in tests/test_autofix_validation.py
GitHub Actions / Python CI / lint-ruff
Ruff (E712)
tests/test_autofix_validation.py:157:8: E712 Avoid equality comparisons to `True`; use `flag:` for truth checks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The PR description lists E501 (line too long) as an intentional Ruff violation that should be caught, but the project's ruff configuration in pyproject.toml explicitly ignores E501 with
ignore = ["E501"]. This intentional violation will not trigger a lint error and therefore will not validate the autofix system's handling of E501 errors.