mirror of
https://github.com/django/django.git
synced 2024-12-28 12:06:22 +00:00
[1.8.x] Moved contrib.contenttypes tests out of contrib.
Backport of 664c038f2c
from master
This commit is contained in:
parent
fb9551189d
commit
ad2c6a756b
@ -1,43 +0,0 @@
|
|||||||
from django.db import models
|
|
||||||
from django.utils.encoding import python_2_unicode_compatible
|
|
||||||
from django.utils.http import urlquote
|
|
||||||
|
|
||||||
|
|
||||||
class ConcreteModel(models.Model):
|
|
||||||
name = models.CharField(max_length=10)
|
|
||||||
|
|
||||||
|
|
||||||
class ProxyModel(ConcreteModel):
|
|
||||||
class Meta:
|
|
||||||
proxy = True
|
|
||||||
|
|
||||||
|
|
||||||
@python_2_unicode_compatible
|
|
||||||
class FooWithoutUrl(models.Model):
|
|
||||||
"""
|
|
||||||
Fake model not defining ``get_absolute_url`` for
|
|
||||||
ContentTypesTests.test_shortcut_view_without_get_absolute_url()
|
|
||||||
"""
|
|
||||||
name = models.CharField(max_length=30, unique=True)
|
|
||||||
|
|
||||||
def __str__(self):
|
|
||||||
return self.name
|
|
||||||
|
|
||||||
|
|
||||||
class FooWithUrl(FooWithoutUrl):
|
|
||||||
"""
|
|
||||||
Fake model defining ``get_absolute_url`` for
|
|
||||||
ContentTypesTests.test_shortcut_view().
|
|
||||||
"""
|
|
||||||
|
|
||||||
def get_absolute_url(self):
|
|
||||||
return "/users/%s/" % urlquote(self.name)
|
|
||||||
|
|
||||||
|
|
||||||
class FooWithBrokenAbsoluteUrl(FooWithoutUrl):
|
|
||||||
"""
|
|
||||||
Fake model defining a ``get_absolute_url`` method containing an error
|
|
||||||
"""
|
|
||||||
|
|
||||||
def get_absolute_url(self):
|
|
||||||
return "/users/%s/" % self.unknown_field
|
|
@ -2,6 +2,7 @@ from __future__ import unicode_literals
|
|||||||
|
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.utils.encoding import python_2_unicode_compatible
|
from django.utils.encoding import python_2_unicode_compatible
|
||||||
|
from django.utils.http import urlquote
|
||||||
|
|
||||||
|
|
||||||
@python_2_unicode_compatible
|
@python_2_unicode_compatible
|
||||||
@ -35,3 +36,43 @@ class SchemeIncludedURL(models.Model):
|
|||||||
|
|
||||||
def get_absolute_url(self):
|
def get_absolute_url(self):
|
||||||
return self.url
|
return self.url
|
||||||
|
|
||||||
|
|
||||||
|
class ConcreteModel(models.Model):
|
||||||
|
name = models.CharField(max_length=10)
|
||||||
|
|
||||||
|
|
||||||
|
class ProxyModel(ConcreteModel):
|
||||||
|
class Meta:
|
||||||
|
proxy = True
|
||||||
|
|
||||||
|
|
||||||
|
@python_2_unicode_compatible
|
||||||
|
class FooWithoutUrl(models.Model):
|
||||||
|
"""
|
||||||
|
Fake model not defining ``get_absolute_url`` for
|
||||||
|
ContentTypesTests.test_shortcut_view_without_get_absolute_url()
|
||||||
|
"""
|
||||||
|
name = models.CharField(max_length=30, unique=True)
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return self.name
|
||||||
|
|
||||||
|
|
||||||
|
class FooWithUrl(FooWithoutUrl):
|
||||||
|
"""
|
||||||
|
Fake model defining ``get_absolute_url`` for
|
||||||
|
ContentTypesTests.test_shortcut_view().
|
||||||
|
"""
|
||||||
|
|
||||||
|
def get_absolute_url(self):
|
||||||
|
return "/users/%s/" % urlquote(self.name)
|
||||||
|
|
||||||
|
|
||||||
|
class FooWithBrokenAbsoluteUrl(FooWithoutUrl):
|
||||||
|
"""
|
||||||
|
Fake model defining a ``get_absolute_url`` method containing an error
|
||||||
|
"""
|
||||||
|
|
||||||
|
def get_absolute_url(self):
|
||||||
|
return "/users/%s/" % self.unknown_field
|
||||||
|
@ -146,7 +146,7 @@ def setup(verbosity, test_labels):
|
|||||||
# these 'tests.migrations' modules don't actually exist, but this lets
|
# these 'tests.migrations' modules don't actually exist, but this lets
|
||||||
# us skip creating migrations for the test models.
|
# us skip creating migrations for the test models.
|
||||||
'auth': 'django.contrib.auth.tests.migrations',
|
'auth': 'django.contrib.auth.tests.migrations',
|
||||||
'contenttypes': 'django.contrib.contenttypes.tests.migrations',
|
'contenttypes': 'contenttypes_tests.migrations',
|
||||||
}
|
}
|
||||||
|
|
||||||
if verbosity > 0:
|
if verbosity > 0:
|
||||||
|
Loading…
Reference in New Issue
Block a user