Fixed #29556 -- Made 'remove_stale_contenttypes --noinput' delete content types.

This commit is contained in:
Jon Dufresne 2018-07-10 05:23:43 -07:00 committed by Tim Graham
parent 178624855a
commit 08ebed5e79
2 changed files with 4 additions and 7 deletions

View File

@ -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:

View File

@ -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."""