flagsmith icon indicating copy to clipboard operation
flagsmith copied to clipboard

test: move pytestmark to module level for migration test module

Open matthewelwell opened this issue 3 months ago • 4 comments

Changes

Factors out the SKIP_MIGRATION_TESTS logic into a custom migrator fixture. This PR is being introduced because one of the tests in the tests/unit/features/test_migrations.py file didn't have the pytest mark decorator. This change also prevents this from occurring again when adding new migration tests.

I've also included some bonus removals of type: ignore statements since I was working in the area.

How did you test this code?

Ran the following 2 example test commands and verified that the tests were / weren't skipped when I expected.

SKIP_MIGRATION_TESTS=true make test opts="-n 0 --dist worksteal tests/unit/features/test_migrations.py"
SKIP_MIGRATION_TESTS=false make test opts="-n 0 --dist worksteal tests/unit/features/test_migrations.py"

matthewelwell avatar Dec 08 '25 16:12 matthewelwell

The latest updates on your projects. Learn more about Vercel for GitHub.

3 Skipped Deployments
Project Deployment Preview Comments Updated (UTC)
docs Ignored Ignored Preview Dec 9, 2025 2:49pm
flagsmith-frontend-preview Ignored Ignored Preview Dec 9, 2025 2:49pm
flagsmith-frontend-staging Ignored Ignored Preview Dec 9, 2025 2:49pm

vercel[bot] avatar Dec 08 '25 16:12 vercel[bot]

Docker builds report

Image Build Status Security report
ghcr.io/flagsmith/flagsmith-api-test:pr-6387 Finished :white_check_mark: Skipped
ghcr.io/flagsmith/flagsmith-frontend:pr-6387 Finished :white_check_mark: Results :white_check_mark:
ghcr.io/flagsmith/flagsmith-api:pr-6387 Finished :white_check_mark: Results :white_check_mark:
ghcr.io/flagsmith/flagsmith:pr-6387 Finished :white_check_mark: Results :white_check_mark:
ghcr.io/flagsmith/flagsmith-private-cloud:pr-6387 Finished :white_check_mark: Results :white_check_mark:

github-actions[bot] avatar Dec 08 '25 16:12 github-actions[bot]

Codecov Report

:white_check_mark: All modified and coverable lines are covered by tests. :white_check_mark: Project coverage is 98.02%. Comparing base (f7ca9cd) to head (f8a8805). :warning: Report is 15 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6387   +/-   ##
=======================================
  Coverage   98.02%   98.02%           
=======================================
  Files        1282     1282           
  Lines       45498    45498           
=======================================
+ Hits        44600    44601    +1     
+ Misses        898      897    -1     

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

codecov[bot] avatar Dec 08 '25 16:12 codecov[bot]

Is it safe to assume all migration tests use the migrator fixture? In that case, consider redefining it in the root conftest.py module like so:

def migrator(request: pytest.FixtureRequest) -> Migrator:
   if settings.SKIP_MIGRATION_TESTS:
      pytest.skip("reason...")
   return request.getfixturevalue("migrator")

Nice idea!

matthewelwell avatar Dec 08 '25 18:12 matthewelwell