Fixed #21079 -- Further normalized table names in inspectdb

Thanks Michael Manfre for the report and Tim Graham for the review.
This commit is contained in:
Claude Paroz 2014-07-05 20:48:57 +02:00
parent 2572c07cc6
commit b144bfb5ce
3 changed files with 20 additions and 3 deletions

View file

@ -179,7 +179,9 @@ class InspectDBTestCase(TestCase):
unsuitable for Python identifiers
"""
out = StringIO()
call_command('inspectdb', stdout=out)
call_command('inspectdb',
table_name_filter=lambda tn: tn.startswith('inspectdb_'),
stdout=out)
output = out.getvalue()
base_name = 'Field' if not connection.features.uppercases_column_names else 'field'
self.assertIn("field = models.IntegerField()", output)
@ -193,6 +195,18 @@ class InspectDBTestCase(TestCase):
else:
self.assertIn("tama_o = models.IntegerField(db_column='tama\\xf1o')", output)
def test_table_name_introspection(self):
"""
Introspection of table names containing special characters,
unsuitable for Python identifiers
"""
out = StringIO()
call_command('inspectdb',
table_name_filter=lambda tn: tn.startswith('inspectdb_'),
stdout=out)
output = out.getvalue()
self.assertIn("class InspectdbSpecialTableName(models.Model):", output)
def test_managed_models(self):
"""Test that by default the command generates models with `Meta.managed = False` (#14305)"""
out = StringIO()