From b604413392b6b0278d3a3e112aea5116fbf2659c Mon Sep 17 00:00:00 2001 From: Marcio Mazza Date: Mon, 13 Jul 2015 14:25:10 -0300 Subject: [PATCH] Improve assertion feedback messages for test --- legacy/test_migration.py | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/legacy/test_migration.py b/legacy/test_migration.py index e2de9cf2c..006691788 100644 --- a/legacy/test_migration.py +++ b/legacy/test_migration.py @@ -24,14 +24,22 @@ def test_get_renames(): else: renamed = set(field_renames[model].keys()) - # all renamed field references correspond to an actual field - assert renamed <= field_names + match_msg_template = 'All %s field names mentioned in renames ' \ + 'must match a %s field' - # check ignored fields in renaming + # all renamed field references correspond to a current field + assert renamed <= field_names, \ + match_msg_template % ('new', 'current') + + # ignored fields are explicitly listed missing_in_renames = field_names - renamed if missing_in_renames: - assert (model, missing_in_renames) in RENAMING_IGNORED_FIELDS - - # all old names correspond to a legacy model field - legacy_model = legacy_app.get_model(model_renames.get(model, model.__name__)) - assert set(field_renames[model].values()) <= {f.name for f in legacy_model._meta.fields} + assert (model, missing_in_renames) in RENAMING_IGNORED_FIELDS, \ + 'Field(s) missing in renames but not explicitly listed' + + # all old names correspond to a legacy field + legacy_model = legacy_app.get_model( + model_renames.get(model, model.__name__)) + legacy_field_names = {f.name for f in legacy_model._meta.fields} + assert set(field_renames[model].values()) <= legacy_field_names, \ + match_msg_template % ('old', 'legacy')