Skip to content

Conversation

Andrew-Chen-Wang
Copy link
Contributor

@Andrew-Chen-Wang Andrew-Chen-Wang commented Dec 22, 2021

Fixes #1054

Description of the Change

Adds a test case to see if a Django version creates a new migration. If it does, decide whether we incorporate the change into the package itself or to simply exclude the Django version that created this regression.

I completely forgot this isn't a Django project, it's a package :)

Checklist

  • PR only contains one change (considered splitting up PR)
  • unit-test added
  • documentation updated
  • CHANGELOG.md updated (only for user relevant changes)
  • author name in AUTHORS

@Andrew-Chen-Wang Andrew-Chen-Wang changed the title Add test to check whether a migration can be created WIP: Add test to check whether a migration can be created Dec 22, 2021
@Andrew-Chen-Wang Andrew-Chen-Wang marked this pull request as draft December 22, 2021 21:19
@Andrew-Chen-Wang
Copy link
Contributor Author

Interestingly enough, I can't actually seem to produce the error in test cases:

    def test_makemigrations(self):
        try:
            call_command("makemigrations", "oauth2_provider", "--check", "--noinput", "--dry-run")
        except SystemExit:
            self.fail("Migration should be created or there is a regression in Django")
        try:
            with self.settings(AUTH_USER_MODEL="auth.User"):
                call_command("makemigrations", "oauth2_provider", "--check", "--noinput", "--dry-run")
        except SystemExit:
            self.fail("Migration should be created or there is a regression in Django")

Run:

tox -e py39-dj40 tests/test_models.py

Output:

tests/test_models.py ...No changes detected in app 'oauth2_provider'
No changes detected in app 'oauth2_provider'
..............^X.......^CERROR: got KeyboardInterrupt signal

@n2ygk
Copy link
Contributor

n2ygk commented Dec 22, 2021

I don't think you can exec a check migrations command because the database context for tests is an in-memory database create just for the test cases to use.

@n2ygk n2ygk mentioned this pull request Dec 23, 2021
5 tasks
@n2ygk n2ygk added this to the 1.7.0 milestone Dec 23, 2021
@n2ygk
Copy link
Contributor

n2ygk commented Jan 4, 2022

Closing this as no longer needed

@n2ygk n2ygk closed this Jan 4, 2022
@Andrew-Chen-Wang Andrew-Chen-Wang deleted the makemigration-check branch January 5, 2022 15:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants