summaryrefslogtreecommitdiff
path: root/tests/inspectdb/tests.py
diff options
context:
space:
mode:
authorMichael Manfre <mmanfre@gmail.com>2013-09-11 11:12:56 -0400
committerTim Graham <timograham@gmail.com>2013-09-11 13:35:26 -0400
commite61cc87129727c66120b67c376feda3533544db1 (patch)
tree38e3b66de4d1e6b104c68c94d9dbc25ce4c28d3f /tests/inspectdb/tests.py
parentabb10db06fb2ecb3e897462ec72417d10b39b8a4 (diff)
downloaddjango-e61cc87129727c66120b67c376feda3533544db1.tar.gz
Fixed #21090 -- Allowed backends to provide dotted field path to inspectdb.
Diffstat (limited to 'tests/inspectdb/tests.py')
-rw-r--r--tests/inspectdb/tests.py24
1 files changed, 23 insertions, 1 deletions
diff --git a/tests/inspectdb/tests.py b/tests/inspectdb/tests.py
index c9093b9e9e..d6f6e478e4 100644
--- a/tests/inspectdb/tests.py
+++ b/tests/inspectdb/tests.py
@@ -2,7 +2,7 @@
from __future__ import unicode_literals
import re
-from unittest import expectedFailure
+from unittest import expectedFailure, skipUnless
from django.core.management import call_command
from django.db import connection
@@ -162,3 +162,25 @@ class InspectDBTestCase(TestCase):
output = out.getvalue()
self.longMessage = False
self.assertIn(" managed = False", output, msg='inspectdb should generate unmanaged models.')
+
+ @skipUnless(connection.vendor == 'sqlite',
+ "Only patched sqlite's DatabaseIntrospection.data_types_reverse for this test")
+ def test_custom_fields(self):
+ """
+ Introspection of columns with a custom field (#21090)
+ """
+ out = StringIO()
+ orig_data_types_reverse = connection.introspection.data_types_reverse
+ try:
+ connection.introspection.data_types_reverse = {
+ 'text': 'myfields.TextField',
+ 'bigint': 'BigIntegerField',
+ }
+ call_command('inspectdb',
+ table_name_filter=lambda tn: tn.startswith('inspectdb_columntypes'),
+ stdout=out)
+ output = out.getvalue()
+ self.assertIn("text_field = myfields.TextField()", output)
+ self.assertIn("big_int_field = models.BigIntegerField()", output)
+ finally:
+ connection.introspection.data_types_reverse = orig_data_types_reverse