Kaydet (Commit) 334096df authored tarafından Adam Chainz's avatar Adam Chainz Kaydeden (comit) Tim Graham

Simplified a contenttypes check test with mock.

üst cd86f035
......@@ -243,15 +243,12 @@ class GenericForeignKeyTests(SimpleTestCase):
@override_settings(INSTALLED_APPS=['django.contrib.auth', 'django.contrib.contenttypes', 'contenttypes_tests'])
def test_generic_foreign_key_checks_are_performed(self):
class MyGenericForeignKey(GenericForeignKey):
def check(self, **kwargs):
return ['performed!']
class Model(models.Model):
content_object = MyGenericForeignKey()
content_object = GenericForeignKey()
errors = checks.run_checks(app_configs=self.apps.get_app_configs())
self.assertEqual(errors, ['performed!'])
with mock.patch.object(GenericForeignKey, 'check') as check:
checks.run_checks(app_configs=self.apps.get_app_configs())
check.assert_called_once_with()
@isolate_apps('contenttypes_tests')
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment