Opened 5 years ago

Last modified 5 years ago

#31123 closed New feature

remove_stale_contenttypes doesn't remove entries for stale apps — at Initial Version

Reported by: Gowtham Kommineni Owned by: nobody
Component: contrib.contenttypes Version: dev
Severity: Normal Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

remove_stale_contenttypes only removes stale content types for stale models in installed apps. It doesn't remove stale content types whose app was either removed or renamed.

Test:
Comment out the line that limits the available apps.
# Speed up tests by avoiding retrieving ContentTypes for all test apps.
# available_apps = ['contenttypes_tests', 'no_models', 'django.contrib.contenttypes']

def test_contenttypes_removed_for_apps_not_in_installed_apps(self):

ContentType.objects.create(app_label='stale_app', model='Fake')
with mock.patch('builtins.input', return_value='yes'), captured_stdout() as stdout:

call_command('remove_stale_contenttypes', verbosity=2)

self.assertIn("Deleting stale content type 'stale_app | Fake'", stdout.getvalue())
self.assertEqual(ContentType.objects.count(), self.before_count)

Change History (0)

Note: See TracTickets for help on using tickets.
Back to Top