mirror of
https://github.com/django/django.git
synced 2024-12-27 03:25:58 +00:00
ad8ebb7006
git-svn-id: http://code.djangoproject.com/svn/django/trunk@17451 bcc190cf-cafb-0310-a4f2-bffc1f526a37
21 lines
891 B
Python
21 lines
891 B
Python
from StringIO import StringIO
|
|
|
|
from django.core.management import call_command
|
|
from django.test import TestCase, skipUnlessDBFeature
|
|
|
|
|
|
class InspectDBTestCase(TestCase):
|
|
|
|
@skipUnlessDBFeature('can_introspect_foreign_keys')
|
|
def test_attribute_name_not_python_keyword(self):
|
|
out = StringIO()
|
|
call_command('inspectdb', stdout=out)
|
|
error_message = "inspectdb generated an attribute name which is a python keyword"
|
|
self.assertNotIn("from = models.ForeignKey(InspectdbPeople)", out.getvalue(), msg=error_message)
|
|
self.assertIn("from_field = models.ForeignKey(InspectdbPeople)", out.getvalue())
|
|
self.assertIn("people_pk = models.ForeignKey(InspectdbPeople, primary_key=True)",
|
|
out.getvalue())
|
|
self.assertIn("people_unique = models.ForeignKey(InspectdbPeople, unique=True)",
|
|
out.getvalue())
|
|
out.close()
|