Simplified a contenttypes check test with mock.
This commit is contained in:
parent
cd86f03591
commit
334096dfac
|
@ -243,15 +243,12 @@ class GenericForeignKeyTests(SimpleTestCase):
|
||||||
|
|
||||||
@override_settings(INSTALLED_APPS=['django.contrib.auth', 'django.contrib.contenttypes', 'contenttypes_tests'])
|
@override_settings(INSTALLED_APPS=['django.contrib.auth', 'django.contrib.contenttypes', 'contenttypes_tests'])
|
||||||
def test_generic_foreign_key_checks_are_performed(self):
|
def test_generic_foreign_key_checks_are_performed(self):
|
||||||
class MyGenericForeignKey(GenericForeignKey):
|
|
||||||
def check(self, **kwargs):
|
|
||||||
return ['performed!']
|
|
||||||
|
|
||||||
class Model(models.Model):
|
class Model(models.Model):
|
||||||
content_object = MyGenericForeignKey()
|
content_object = GenericForeignKey()
|
||||||
|
|
||||||
errors = checks.run_checks(app_configs=self.apps.get_app_configs())
|
with mock.patch.object(GenericForeignKey, 'check') as check:
|
||||||
self.assertEqual(errors, ['performed!'])
|
checks.run_checks(app_configs=self.apps.get_app_configs())
|
||||||
|
check.assert_called_once_with()
|
||||||
|
|
||||||
|
|
||||||
@isolate_apps('contenttypes_tests')
|
@isolate_apps('contenttypes_tests')
|
||||||
|
|
Loading…
Reference in New Issue