-
-
Notifications
You must be signed in to change notification settings - Fork 31.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixed #32900 -- Improved migrations questioner prompts. #14607
Conversation
074e0b6
to
03cd354
Compare
06adafe
to
ae54f97
Compare
3ad2cfa
to
7cd7856
Compare
Hiya @mateoradman could you target the |
Sure, no problem! 👍 |
d452cf7
to
a4516a6
Compare
I think this one is ready to be merged. Thanks for everyone’s suggestions and involvement. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mateoradman Thanks for this patch 👍 I left comments.
b2e4d64
to
4585290
Compare
Hi @mateoradman -- thank you for your efforts here. 👍 If you've fixed all of the review comments you can untick 'needs tests' and 'needs improvement' on trac so it can go back into the review queue. |
I don't see any new tests requested in the #14607 (comment) 🤔 |
Hi @felixxm, I remember that I could not find any other message that can be tested here. If you identify that I missed something, please let me know and I will do it asap. |
Thanks for the quick reply. I was wondering, is this the blocker?
If so, no biggie. Just also assert that it raises SystemExit. Something like... diff --git a/tests/migrations/test_commands.py b/tests/migrations/test_commands.py
index daeeaf8edb..621656429b 100644
--- a/tests/migrations/test_commands.py
+++ b/tests/migrations/test_commands.py
@@ -16,6 +16,7 @@ from django.db.backends.utils import truncate_name
from django.db.migrations.exceptions import InconsistentMigrationHistory
from django.db.migrations.recorder import MigrationRecorder
from django.test import TestCase, override_settings, skipUnlessDBFeature
+from django.test.utils import captured_stdout
from .models import UnicodeModel, UnserializableModel
from .routers import TestRouter
@@ -1365,6 +1366,22 @@ class MakeMigrationsTests(MigrationTestBase):
call_command("makemigrations", "migrations", interactive=False, stdout=out)
self.assertIn("Alter field slug on author", out.getvalue())
+ @mock.patch('builtins.input', return_value='2')
+ def test_makemigrations_interactive_not_null_addition(self, mock):
+ class Entry(models.Model):
+ title = models.CharField(max_length=255)
+ archived = models.BooleanField(null=False)
+
+ class Meta:
+ app_label = 'migrations'
+
+ with captured_stdout() as out:
+ # this is the template you patch right above this, possibly find a better one
+ with self.temporary_migration_module(module='migrations.test_auto_now_add'):
+ with self.assertRaises(SystemExit):
+ call_command('makemigrations', 'migrations', interactive=True)
+ self.assertIn('assertion will fail', out.getvalue())
+
def test_makemigrations_non_interactive_no_model_rename(self):
"""
makemigrations adds and removes a possible model rename in Giving you the opportunity to assert against the messages you changed in this patch:
The coverage report might be helpful for spotting what's not tested. At least, that's where I would start. Thanks for giving this module some ❤️ ! |
4585290
to
4176976
Compare
Thanks for the tests, Mateo. If the messages you've edited are now covered by your tests, could you uncheck Needs Tests on the ticket? Thanks. |
Don
Done, thanks! |
…eMigrationQuestioner.ask_not_null_alteration().
4176976
to
2a7e311
Compare
@mateoradman Thanks 👍 I reorganized commits and pushed edits to tests. |
…ive voice and avoid personal pronouns.