From 342074f4a434a38d1b3a569e517ba9f1ce6ed946 Mon Sep 17 00:00:00 2001 From: Michael Manfre Date: Thu, 2 Jul 2015 22:09:51 -0400 Subject: [PATCH] [1.8.x] Fixed #25055 -- Made m2m long name testing friendlier for 3rd party databases. Backport of f9c3587b51487179cf3fb92b509790f4610d6012 from master --- tests/invalid_models_tests/test_models.py | 26 +++++++++++++---------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/tests/invalid_models_tests/test_models.py b/tests/invalid_models_tests/test_models.py index 87a099f3a9..8417d5507e 100644 --- a/tests/invalid_models_tests/test_models.py +++ b/tests/invalid_models_tests/test_models.py @@ -328,17 +328,21 @@ class FieldNamesTests(IsolatedModelsTestCase): # First error because of M2M field set on the model with long name. m2m_long_name = "verylongmodelnamezzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz_id" - expected = [ - Error( - 'Autogenerated column name too long for M2M field "%s". ' - 'Maximum length is "%s" for database "%s".' - % (m2m_long_name, self.max_column_name_length, self.column_limit_db_alias), - hint=("Use 'through' to create a separate model for " - "M2M and then set column_name using 'db_column'."), - obj=ModelWithLongField, - id='models.E019', - ) - ] + if self.max_column_name_length > len(m2m_long_name): + # Some databases support names longer than the test name. + expected = [] + else: + expected = [ + Error( + 'Autogenerated column name too long for M2M field "%s". ' + 'Maximum length is "%s" for database "%s".' + % (m2m_long_name, self.max_column_name_length, self.column_limit_db_alias), + hint=("Use 'through' to create a separate model for " + "M2M and then set column_name using 'db_column'."), + obj=ModelWithLongField, + id='models.E019', + ) + ] # Second error because the FK specified in the `through` model # `m2msimple` has auto-genererated name longer than allowed.