Ticket #25280: 25280-test.diff

File 25280-test.diff, 1.7 KB (added by Tim Graham, 9 years ago)
  • tests/migrations/test_autodetector.py

    diff --git a/tests/migrations/test_autodetector.py b/tests/migrations/test_autodetector.py
    index 5caec12..4baeed4 100644
    a b class AutodetectorTests(TestCase):  
    997997        self.assertOperationAttributes(changes, "testapp", 0, 0, old_name="Author", new_name="NewAuthor")
    998998        self.assertOperationAttributes(changes, "testapp", 0, 1, name="newauthor", table="author_three")
    999999
     1000    def test_lazy_str(self):
     1001        from django.core.validators import validate_slug
     1002        import re
     1003        from_state = ModelState(
     1004            "a", "model", [(
     1005                "id", models.AutoField(
     1006                    primary_key=True,
     1007                    validators=[(
     1008                        'django.core.validators.RegexValidator',
     1009                        [re.compile('^[-a-zA-Z0-9_]+\\Z'), "Enter a valid 'slug' consisting of letters, numbers, underscores or hyphens.", 'invalid'],
     1010                        {},
     1011                    )]
     1012                )
     1013            )]
     1014        )
     1015        to_state = ModelState(
     1016            "a", "model", [("id", models.AutoField(primary_key=True, validators=[validate_slug]))]
     1017        )
     1018        before = self.make_project_state([from_state])
     1019        after = self.make_project_state([to_state])
     1020        autodetector = MigrationAutodetector(before, after)
     1021        changes = autodetector._detect_changes()
     1022        if len(changes) > 0:
     1023            ops = ', '.join(o.__class__.__name__ for o in changes['a'][0].operations)
     1024            self.fail('Created operation(s) %s' % (ops,))
     1025
    10001026    def test_empty_foo_together(self):
    10011027        """
    10021028        #23452 - Empty unique/index_together shouldn't generate a migration.
Back to Top