Ticket #16737: 16737-test.diff

File 16737-test.diff, 1.7 KB (added by Claude Paroz, 12 years ago)

Test of a non-ascii column name

  • tests/regressiontests/inspectdb/models.py

    diff --git a/tests/regressiontests/inspectdb/models.py b/tests/regressiontests/inspectdb/models.py
    index 4a66214..1966c46 100644
    a b  
     1# -*- encoding: utf-8 -*-
     2from __future__ import unicode_literals
     3
    14from django.db import models
    25
    36
    class SpecialColumnName(models.Model):  
    2831    field_field_2 = models.IntegerField(db_column='__field')
    2932    # Other chars
    3033    prc_x = models.IntegerField(db_column='prc(%) x')
     34    non_ascii = models.IntegerField(db_column='tamaño')
  • tests/regressiontests/inspectdb/tests.py

    diff --git a/tests/regressiontests/inspectdb/tests.py b/tests/regressiontests/inspectdb/tests.py
    index 484e7f4..5956231 100644
    a b  
     1# -*- encoding: utf-8 -*-
    12from __future__ import unicode_literals
    23
    34from django.core.management import call_command
    45from django.test import TestCase, skipUnlessDBFeature
    5 from django.utils.six import StringIO
     6from django.utils.six import PY3, StringIO
    67
    78
    89class InspectDBTestCase(TestCase):
    class InspectDBTestCase(TestCase):  
    7172        self.assertIn("field_field_0 = models.IntegerField(db_column='Field__')", output)
    7273        self.assertIn("field_field_1 = models.IntegerField(db_column='__field')", output)
    7374        self.assertIn("prc_x = models.IntegerField(db_column='prc(%) x')", output)
     75        if PY3:
     76            # Python 3 allows non-ascii identifiers
     77            self.assertIn("tamaño = models.IntegerField()", output)
     78        else:
     79            self.assertIn("tama_o = models.IntegerField(db_column='tama\\xf1o')", output)
Back to Top