Skip to content

refactor(tests): plugin tests to follow test conventions and fix regex warning#3244

Merged
talsperre merged 4 commits into
Netflix:masterfrom
agsaru:refactor-pytest-plugins
Jun 12, 2026
Merged

refactor(tests): plugin tests to follow test conventions and fix regex warning#3244
talsperre merged 4 commits into
Netflix:masterfrom
agsaru:refactor-pytest-plugins

Conversation

@agsaru

@agsaru agsaru commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

PR Type

  • Bug fix
  • New feature
  • Core Runtime change (higher bar -- see CONTRIBUTING.md)
  • Docs / tooling
  • Refactoring

Summary

Copilot AI review requested due to automatic review settings June 8, 2026 18:52

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

This PR updates and refactors plugin-related unit tests, simplifying test structure and modernizing mocking/fixtures while making a small regex-string fix in the Pip plugin.

Changes:

  • Refactor conda parser tests from class-based to function-based tests and consolidate invalid-input cases via parametrization.
  • Update Pip indices test mocking approach and remove unittest.mock usage.
  • Refactor conda environment unit tests to use tmp_path and extract a thread worker helper; fix regex literal usage in pip.py.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.

File Description
test/plugins/pip/test_pip_indices.py Switches mocking approach for _call in a regression test.
test/plugins/conda/test_parsers.py Refactors tests into standalone functions and parametrizes invalid cases.
test/plugins/conda/test_conda_environment_unit.py Refactors concurrency/cleanup tests to use tmp_path and a helper worker function.
metaflow/plugins/pypi/pip.py Uses a raw regex string for \w* to avoid invalid escape behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread test/plugins/conda/test_conda_environment_unit.py Outdated
Comment thread test/plugins/conda/test_conda_environment_unit.py Outdated
Comment thread test/plugins/conda/test_conda_environment_unit.py Outdated
Comment thread test/plugins/pip/test_pip_indices.py
Comment thread test/plugins/pip/test_pip_indices.py
@greptile-apps

greptile-apps Bot commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR refactors three plugin test files to follow pytest conventions (module-level functions instead of classes, tmp_path fixture, pytest.importorskip, @pytest.mark.parametrize) and fixes a DeprecationWarning in pip.py by adding the r prefix to a bare regex string.

  • pip.py: "\w*"r"\w*" to suppress the invalid escape sequence warning.
  • test_conda_environment_unit.py / test_parsers.py: class-based tests converted to top-level functions; manual tempfile usage replaced with tmp_path; platform-specific fcntl gated behind pytest.importorskip.
  • test_pip_indices.py: monkeypatch + MagicMock replaced with mocker.patch.object (pytest-mock is already a declared dev dependency).

Confidence Score: 5/5

All changes are confined to test files and a one-character fix in a production regex; no runtime behaviour is altered.

The production change is a trivial raw-string prefix that removes a warning without touching logic. The test refactors are mechanically equivalent to the code they replace, use only fixtures already available in the declared dependencies, and the platform-sensitive fcntl import is properly guarded with pytest.importorskip.

No files require special attention.

Important Files Changed

Filename Overview
metaflow/plugins/pypi/pip.py Adds raw string prefix to regex pattern to fix DeprecationWarning; minimal single-line change.
test/plugins/conda/test_conda_environment_unit.py Refactored from class-based to function-based tests; uses tmp_path fixture, pytest.importorskip for fcntl, and contextlib.suppress for cleaner cleanup handling.
test/plugins/conda/test_parsers.py Refactored class-based tests to module-level functions; consolidated three error-case tests into a single parametrized test.
test/plugins/pip/test_pip_indices.py Replaced monkeypatch+MagicMock with mocker.patch.object; pytest-mock is already a declared dev dependency so the change is safe.

Reviews (4): Last reviewed commit: "fix: scope fcntl skip in conda environme..." | Re-trigger Greptile

Comment thread test/plugins/conda/test_conda_environment_unit.py Outdated
@codecov

codecov Bot commented Jun 8, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 1 line in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (master@732ca76). Learn more about missing BASE report.

Files with missing lines Patch % Lines
metaflow/plugins/pypi/pip.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##             master    #3244   +/-   ##
=========================================
  Coverage          ?   29.08%           
=========================================
  Files             ?      381           
  Lines             ?    52513           
  Branches          ?     9266           
=========================================
  Hits              ?    15275           
  Misses            ?    36203           
  Partials          ?     1035           

☔ View full report in Codecov by Harness.
📢 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@talsperre
talsperre merged commit fa56b61 into Netflix:master Jun 12, 2026
39 checks passed
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.

3 participants