diff options
author | Adam Chainz <adam@adamj.eu> | 2017-01-07 10:14:24 -0500 |
---|---|---|
committer | Tim Graham <timograham@gmail.com> | 2017-01-07 10:24:40 -0500 |
commit | 334096dfac60fbc494e17b9a9ba22d098334c73b (patch) | |
tree | c7069e2a3f3e5dc2a3bd0f85f59588a92b23dd77 /tests/contenttypes_tests | |
parent | cd86f03591c4147b7c39e226a0d4bc4dc295d2ca (diff) | |
download | django-334096dfac60fbc494e17b9a9ba22d098334c73b.tar.gz |
Simplified a contenttypes check test with mock.
Diffstat (limited to 'tests/contenttypes_tests')
-rw-r--r-- | tests/contenttypes_tests/tests.py | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/tests/contenttypes_tests/tests.py b/tests/contenttypes_tests/tests.py index 5845c02af6..db97557f24 100644 --- a/tests/contenttypes_tests/tests.py +++ b/tests/contenttypes_tests/tests.py @@ -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') |