I looked at your solution, and I find it both ingenious and easy to test for i18n support when you don't have translation strings. But I'm afraid that the translation package is something that always works and that we take for granted, therefore, seeing its insides in a highly commented test code will at least make me run away from fear (chuckle).
I think that creating a test application added to INSTALLED_APPS in the test settings, which provides its own translations, is a much cleaner approach. Your tests will be simplified to translation.activate('fr'); self.assertEqual('xxx_anything', gettext('anything'), 'i18n support should be activated.') translation.activate('fr'); self.assertEqual('xxx_anything', gettext('anything'), 'i18n support should be activated.') .
With simple tests, other developers could quickly track and see that the test application package contains the /locale directory, which should immediately document your approach.
source share