Skip to content

Fixed factory_boy post-generation deprecation warnings in test factories - #2595

Merged
ObadaS merged 1 commit into
developfrom
fix_factory_deprecation_warnings
Oct 1, 2026
Merged

ObadaS merged 1 commit into
developfrom
fix_factory_deprecation_warnings

Conversation

@ihsaan-ullah

Copy link
Copy Markdown
Collaborator

Description

  • skip_postgeneration_save = True added to
    • UserFactory
    • CompetitionFactory
    • TaskFactory
    • PhaseFactory
    • SubmissionScoreFactory
  • UserFactory super_user hook now saves the user
  • CompetitionFactory collaborators hook now saves the competition after adding collaborators

Why these changes?

  • factory_boy showed a deprecation warning every time these factories were used in tests
  • Today factory_boy saves the object again after a hook runs; the next major version will stop doing this
  • The new setting turns that extra save off, which removes the warnings
  • Two hooks needed the extra save, so they now save on their own:
    • super_user sets is_superuser and is_staff, which must be saved to the database
    • Competition.save() is what makes collaborators approved participants
  • The other three hooks only add many-to-many links, which are saved right away, so they need no save

A checklist for hand testing

  • without this change you will see some factory_boy warnings when running the tests, check that the warnings are gone after this change

Checklist

  • Code review by me
  • Hand tested by me
  • I'm proud of my work
  • Code review by reviewer
  • Hand tested by reviewer
  • CircleCi tests are passing
  • Ready to merge

@ObadaS
ObadaS self-requested a review October 1, 2026 09:15
- skip_postgeneration_save = True added to UserFactory, CompetitionFactory, TaskFactory, PhaseFactory and SubmissionScoreFactory
- UserFactory super_user hook now saves the user
- CompetitionFactory collaborators hook now saves the competition after adding collaborators
@ObadaS
ObadaS force-pushed the fix_factory_deprecation_warnings branch from dbecbc8 to 721d830 Compare October 1, 2026 09:15
@ObadaS
ObadaS merged commit 7bd6fa0 into develop Oct 1, 2026
1 check passed
@ObadaS
ObadaS deleted the fix_factory_deprecation_warnings branch October 1, 2026 09:28
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