Fixed #29556 -- Made 'remove_stale_contenttypes --noinput' delete content types.
This commit is contained in:
parent
178624855a
commit
08ebed5e79
|
@ -60,7 +60,7 @@ Are you sure you want to delete these content types?
|
||||||
If you're unsure, answer 'no'.\n""" % content_type_display)
|
If you're unsure, answer 'no'.\n""" % content_type_display)
|
||||||
ok_to_delete = input("Type 'yes' to continue, or 'no' to cancel: ")
|
ok_to_delete = input("Type 'yes' to continue, or 'no' to cancel: ")
|
||||||
else:
|
else:
|
||||||
ok_to_delete = False
|
ok_to_delete = 'yes'
|
||||||
|
|
||||||
if ok_to_delete == 'yes':
|
if ok_to_delete == 'yes':
|
||||||
for ct in to_remove:
|
for ct in to_remove:
|
||||||
|
|
|
@ -52,14 +52,11 @@ class RemoveStaleContentTypesTests(TestCase):
|
||||||
self.assertEqual(ContentType.objects.count(), self.before_count)
|
self.assertEqual(ContentType.objects.count(), self.before_count)
|
||||||
|
|
||||||
def test_interactive_false(self):
|
def test_interactive_false(self):
|
||||||
"""
|
"""non-interactive mode deletes stale content types."""
|
||||||
non-interactive mode of remove_stale_contenttypes doesn't delete
|
|
||||||
stale content types.
|
|
||||||
"""
|
|
||||||
with captured_stdout() as stdout:
|
with captured_stdout() as stdout:
|
||||||
call_command('remove_stale_contenttypes', interactive=False, verbosity=2)
|
call_command('remove_stale_contenttypes', interactive=False, verbosity=2)
|
||||||
self.assertIn("Stale content types remain.", stdout.getvalue())
|
self.assertIn('Deleting stale content type', stdout.getvalue())
|
||||||
self.assertEqual(ContentType.objects.count(), self.before_count + 1)
|
self.assertEqual(ContentType.objects.count(), self.before_count)
|
||||||
|
|
||||||
def test_unavailable_content_type_model(self):
|
def test_unavailable_content_type_model(self):
|
||||||
"""A ContentType isn't created if the model isn't available."""
|
"""A ContentType isn't created if the model isn't available."""
|
||||||
|
|
Loading…
Reference in New Issue