tests.py 656 B

12345678910111213141516
  1. from StringIO import StringIO
  2. from django.core.management import call_command
  3. from django.test import TestCase, skipUnlessDBFeature
  4. class InspectDBTestCase(TestCase):
  5. @skipUnlessDBFeature('can_introspect_foreign_keys')
  6. def test_attribute_name_not_python_keyword(self):
  7. out = StringIO()
  8. call_command('inspectdb', stdout=out)
  9. error_message = "inspectdb generated an attribute name which is a python keyword"
  10. self.assertNotIn("from = models.ForeignKey(InspectdbPeople)", out.getvalue(), msg=error_message)
  11. self.assertIn("from_field = models.ForeignKey(InspectdbPeople)", out.getvalue())
  12. out.close()