From d00fb4d2d6f375ace2b4fe35a4acde8e476000d2 Mon Sep 17 00:00:00 2001 From: Mateo Radman <48420316+mateoradman@users.noreply.github.com> Date: Sat, 17 Jul 2021 10:46:24 +0300 Subject: [PATCH] Refs #32900 -- Added test for ignoring the default value in InteractiveMigrationQuestioner.ask_not_null_alteration(). --- tests/migrations/test_questioner.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/migrations/test_questioner.py b/tests/migrations/test_questioner.py index e17dd04ab6..9ab7756ab5 100644 --- a/tests/migrations/test_questioner.py +++ b/tests/migrations/test_questioner.py @@ -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)