Skip to content

fix(tests): resolve ruff F821 errors for DuplicateTest in test_duplicates.py#148

Merged
jacobdadams merged 2 commits intodel-bugfrom
copilot/sub-pr-147
Mar 20, 2026
Merged

fix(tests): resolve ruff F821 errors for DuplicateTest in test_duplicates.py#148
jacobdadams merged 2 commits intodel-bugfrom
copilot/sub-pr-147

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Mar 20, 2026

Ruff could not statically resolve DuplicateTest because it was injected into module globals dynamically via globals()["DuplicateTest"] = _DuplicateTest inside a pytest fixture.

Changes

  • Module-level mocking + direct import: sys.modules patching for arcpy, its submodules, and xxhash is now done at module level before a direct from sweeper.sweepers.duplicates import DuplicateTest, making the name statically visible to ruff. Uses # ruff: isort: off/on guards to suppress the intentional import order violation — consistent with test_addresses.py.
  • Restored cleanup fixture: A _restore_sys_modules module-scoped fixture undoes the sys.modules patching after all tests in the module complete, preserving test isolation.
# ruff: isort: off
arcpy_mock = MagicMock()
sys.modules["arcpy"] = arcpy_mock
# ... other submodules + xxhash ...

from sweeper.sweepers.duplicates import DuplicateTest  # noqa: E402
# ruff: isort: on

@pytest.fixture(autouse=True, scope="module")
def _restore_sys_modules():
    yield
    # restore originals ...

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

…dule level

Co-authored-by: jacobdadams <38168030+jacobdadams@users.noreply.github.com>
Agent-Logs-Url: https://github.com/agrc/sweeper/sessions/ba6f55df-5b0c-43fd-a7dd-25596cf24014
Copilot AI changed the title [WIP] [WIP] Address feedback on test linting issues in Sweeper PR fix(tests): resolve ruff F821 errors for DuplicateTest in test_duplicates.py Mar 20, 2026
Copilot AI requested a review from jacobdadams March 20, 2026 16:40
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 20, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (del-bug@41715a0). Learn more about missing BASE report.

Additional details and impacted files
@@            Coverage Diff             @@
##             del-bug     #148   +/-   ##
==========================================
  Coverage           ?   36.43%           
==========================================
  Files              ?       13           
  Lines              ?      785           
  Branches           ?      139           
==========================================
  Hits               ?      286           
  Misses             ?      492           
  Partials           ?        7           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jacobdadams jacobdadams marked this pull request as ready for review March 20, 2026 16:42
@jacobdadams jacobdadams merged commit aac15b5 into del-bug Mar 20, 2026
4 checks passed
@jacobdadams jacobdadams deleted the copilot/sub-pr-147 branch March 20, 2026 16:42
jacobdadams added a commit that referenced this pull request Mar 23, 2026
…ates.py (#148)

* Initial plan

* fix(tests): resolve ruff F821 errors by importing DuplicateTest at module level

Co-authored-by: jacobdadams <38168030+jacobdadams@users.noreply.github.com>
Agent-Logs-Url: https://github.com/agrc/sweeper/sessions/ba6f55df-5b0c-43fd-a7dd-25596cf24014

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: jacobdadams <38168030+jacobdadams@users.noreply.github.com>
@ugrc-release-bot ugrc-release-bot bot mentioned this pull request Mar 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants