diff options
| author | Russell Keith-Magee <russell@keith-magee.com> | 2014-01-20 10:45:21 +0800 |
|---|---|---|
| committer | Russell Keith-Magee <russell@keith-magee.com> | 2014-01-20 10:45:21 +0800 |
| commit | d818e0c9b2b88276cc499974f9eee893170bf0a8 (patch) | |
| tree | 13ef631f7ba50bf81fa36f484abf925ba8172651 /tests/model_validation | |
| parent | 6e7bd0b63bd01949ac4fd647f2597639bed0c3a2 (diff) | |
Fixed #16905 -- Added extensible checks (nee validation) framework
This is the result of Christopher Medrela's 2013 Summer of Code project.
Thanks also to Preston Holmes, Tim Graham, Anssi Kääriäinen, Florian
Apolloner, and Alex Gaynor for review notes along the way.
Also: Fixes #8579, fixes #3055, fixes #19844.
Diffstat (limited to 'tests/model_validation')
| -rw-r--r-- | tests/model_validation/tests.py | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/tests/model_validation/tests.py b/tests/model_validation/tests.py index 225656e4cb..b166f0c072 100644 --- a/tests/model_validation/tests.py +++ b/tests/model_validation/tests.py @@ -1,7 +1,5 @@ from django.core import management -from django.core.management.validation import ( - ModelErrorCollection, validate_model_signals -) +from django.core.checks import run_checks, Error from django.db.models.signals import post_init from django.test import TestCase from django.utils import six @@ -24,26 +22,32 @@ class ModelValidationTest(TestCase): # See: https://code.djangoproject.com/ticket/20430 # * related_name='+' doesn't clash with another '+' # See: https://code.djangoproject.com/ticket/21375 - management.call_command("validate", stdout=six.StringIO()) + management.call_command("check", stdout=six.StringIO()) def test_model_signal(self): unresolved_references = post_init.unresolved_references.copy() post_init.connect(on_post_init, sender='missing-app.Model') post_init.connect(OnPostInit(), sender='missing-app.Model') - e = ModelErrorCollection(six.StringIO()) - validate_model_signals(e) - self.assertSetEqual( - set(e.errors), - {( - 'model_validation.tests', + + errors = run_checks() + expected = [ + Error( "The `on_post_init` function was connected to the `post_init` " "signal with a lazy reference to the 'missing-app.Model' " - "sender, which has not been installed." - ), ( - 'model_validation.tests', + "sender, which has not been installed.", + hint=None, + obj='model_validation.tests', + id='E014', + ), + Error( "An instance of the `OnPostInit` class was connected to " "the `post_init` signal with a lazy reference to the " - "'missing-app.Model' sender, which has not been installed." - )} - ) + "'missing-app.Model' sender, which has not been installed.", + hint=None, + obj='model_validation.tests', + id='E014', + ) + ] + self.assertEqual(errors, expected) + post_init.unresolved_references = unresolved_references |
