diff --git a/django/contrib/contenttypes/management/commands/remove_stale_contenttypes.py b/django/contrib/contenttypes/management/commands/remove_stale_contenttypes.py index 9cc559dc1d..4d282d524e 100644 --- a/django/contrib/contenttypes/management/commands/remove_stale_contenttypes.py +++ b/django/contrib/contenttypes/management/commands/remove_stale_contenttypes.py @@ -60,7 +60,7 @@ Are you sure you want to delete these content types? If you're unsure, answer 'no'.\n""" % content_type_display) ok_to_delete = input("Type 'yes' to continue, or 'no' to cancel: ") else: - ok_to_delete = False + ok_to_delete = 'yes' if ok_to_delete == 'yes': for ct in to_remove: diff --git a/tests/contenttypes_tests/test_management.py b/tests/contenttypes_tests/test_management.py index fa80c843d7..3e375518c9 100644 --- a/tests/contenttypes_tests/test_management.py +++ b/tests/contenttypes_tests/test_management.py @@ -52,14 +52,11 @@ class RemoveStaleContentTypesTests(TestCase): self.assertEqual(ContentType.objects.count(), self.before_count) def test_interactive_false(self): - """ - non-interactive mode of remove_stale_contenttypes doesn't delete - stale content types. - """ + """non-interactive mode deletes stale content types.""" with captured_stdout() as stdout: call_command('remove_stale_contenttypes', interactive=False, verbosity=2) - self.assertIn("Stale content types remain.", stdout.getvalue()) - self.assertEqual(ContentType.objects.count(), self.before_count + 1) + self.assertIn('Deleting stale content type', stdout.getvalue()) + self.assertEqual(ContentType.objects.count(), self.before_count) def test_unavailable_content_type_model(self): """A ContentType isn't created if the model isn't available."""