Refs -- Added test for ignoring the default value in InteractiveMigrationQuestioner.ask_not_null_alteration().
@@ -4,6 +4,7 @@ from unittest import mock
from django.db.migrations.questioner import (
InteractiveMigrationQuestioner, MigrationQuestioner,
)
+from django.db.models import NOT_PROVIDED
from django.test import SimpleTestCase
from django.test.utils import captured_stdout, override_settings
@@ -23,3 +24,10 @@ class QuestionerTests(SimpleTestCase):
with captured_stdout():
value = questioner._ask_default()
self.assertEqual(value, datetime.timedelta(days=1))
+
+ @mock.patch('builtins.input', return_value='2')
+ def test_ask_not_null_alteration_not_provided(self, mock):
+ questioner = InteractiveMigrationQuestioner()
+ with captured_stdout():
+ question = questioner.ask_not_null_alteration('field_name', 'model_name')
+ self.assertEqual(question, NOT_PROVIDED)
