diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/modeltests/custom_pk/models.py | 3 | ||||
-rw-r--r-- | tests/modeltests/empty/__init__.py | 0 | ||||
-rw-r--r-- | tests/modeltests/empty/models.py | 24 | ||||
-rw-r--r-- | tests/modeltests/generic_relations/__init__.py | 0 | ||||
-rw-r--r-- | tests/modeltests/generic_relations/models.py | 108 | ||||
-rw-r--r-- | tests/modeltests/get_or_create/__init__.py | 0 | ||||
-rw-r--r-- | tests/modeltests/get_or_create/models.py | 52 | ||||
-rw-r--r-- | tests/modeltests/invalid_models/models.py | 2 | ||||
-rw-r--r-- | tests/modeltests/properties/models.py | 12 | ||||
-rw-r--r-- | tests/othertests/templates.py | 101 | ||||
-rwxr-xr-x | tests/runtests.py | 14 |
11 files changed, 300 insertions, 16 deletions
diff --git a/tests/modeltests/custom_pk/models.py b/tests/modeltests/custom_pk/models.py index 6193852adf..f7b790ca21 100644 --- a/tests/modeltests/custom_pk/models.py +++ b/tests/modeltests/custom_pk/models.py @@ -8,7 +8,8 @@ this behavior by explicitly adding ``primary_key=True`` to a field. from django.db import models class Employee(models.Model): - employee_code = models.CharField(maxlength=10, primary_key=True) + employee_code = models.CharField(maxlength=10, primary_key=True, + db_column = 'code') first_name = models.CharField(maxlength=20) last_name = models.CharField(maxlength=20) class Meta: diff --git a/tests/modeltests/empty/__init__.py b/tests/modeltests/empty/__init__.py new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/tests/modeltests/empty/__init__.py diff --git a/tests/modeltests/empty/models.py b/tests/modeltests/empty/models.py new file mode 100644 index 0000000000..c50878398d --- /dev/null +++ b/tests/modeltests/empty/models.py @@ -0,0 +1,24 @@ +""" +Empty model tests + +These test that things behave sensibly for the rare corner-case of a model with +no fields. +""" + +from django.db import models + +class Empty(models.Model): + pass + +API_TESTS = """ +>>> m = Empty() +>>> m.id +>>> m.save() +>>> m2 = Empty() +>>> m2.save() +>>> len(Empty.objects.all()) +2 +>>> m.id is not None +True + +""" diff --git a/tests/modeltests/generic_relations/__init__.py b/tests/modeltests/generic_relations/__init__.py new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/tests/modeltests/generic_relations/__init__.py diff --git a/tests/modeltests/generic_relations/models.py b/tests/modeltests/generic_relations/models.py new file mode 100644 index 0000000000..a9a775ad6e --- /dev/null +++ b/tests/modeltests/generic_relations/models.py @@ -0,0 +1,108 @@ +""" +33. Generic relations + +Generic relations let an object have a foreign key to any object through a +content-type/object-id field. A generic foreign key can point to any object, +be it animal, vegetable, or mineral. + +The cannonical example is tags (although this example implementation is *far* +from complete). +""" + +from django.db import models +from django.contrib.contenttypes.models import ContentType + +class TaggedItem(models.Model): + """A tag on an item.""" + tag = models.SlugField() + content_type = models.ForeignKey(ContentType) + object_id = models.PositiveIntegerField() + + content_object = models.GenericForeignKey() + + class Meta: + ordering = ["tag"] + + def __str__(self): + return self.tag + +class Animal(models.Model): + common_name = models.CharField(maxlength=150) + latin_name = models.CharField(maxlength=150) + + tags = models.GenericRelation(TaggedItem) + + def __str__(self): + return self.common_name + +class Vegetable(models.Model): + name = models.CharField(maxlength=150) + is_yucky = models.BooleanField(default=True) + + tags = models.GenericRelation(TaggedItem) + + def __str__(self): + return self.name + +class Mineral(models.Model): + name = models.CharField(maxlength=150) + hardness = models.PositiveSmallIntegerField() + + # note the lack of an explicit GenericRelation here... + + def __str__(self): + return self.name + +API_TESTS = """ +# Create the world in 7 lines of code... +>>> lion = Animal(common_name="Lion", latin_name="Panthera leo") +>>> platypus = Animal(common_name="Platypus", latin_name="Ornithorhynchus anatinus") +>>> eggplant = Vegetable(name="Eggplant", is_yucky=True) +>>> bacon = Vegetable(name="Bacon", is_yucky=False) +>>> quartz = Mineral(name="Quartz", hardness=7) +>>> for o in (lion, platypus, eggplant, bacon, quartz): +... o.save() + +# Objects with declared GenericRelations can be tagged directly -- the API +# mimics the many-to-many API +>>> lion.tags.create(tag="yellow") +<TaggedItem: yellow> +>>> lion.tags.create(tag="hairy") +<TaggedItem: hairy> +>>> bacon.tags.create(tag="fatty") +<TaggedItem: fatty> +>>> bacon.tags.create(tag="salty") +<TaggedItem: salty> + +>>> lion.tags.all() +[<TaggedItem: hairy>, <TaggedItem: yellow>] +>>> bacon.tags.all() +[<TaggedItem: fatty>, <TaggedItem: salty>] + +# You can easily access the content object like a foreign key +>>> t = TaggedItem.objects.get(tag="salty") +>>> t.content_object +<Vegetable: Bacon> + +# Recall that the Mineral class doesn't have an explicit GenericRelation +# defined. That's OK since you can create TaggedItems explicitally. +>>> tag1 = TaggedItem(content_object=quartz, tag="shiny") +>>> tag2 = TaggedItem(content_object=quartz, tag="clearish") +>>> tag1.save() +>>> tag2.save() + +# However, not having the convience takes a small toll when it comes +# to do lookups +>>> from django.contrib.contenttypes.models import ContentType +>>> ctype = ContentType.objects.get_for_model(quartz) +>>> TaggedItem.objects.filter(content_type__pk=ctype.id, object_id=quartz.id) +[<TaggedItem: clearish>, <TaggedItem: shiny>] + +# You can set a generic foreign key in the way you'd expect +>>> tag1.content_object = platypus +>>> tag1.save() +>>> platypus.tags.all() +[<TaggedItem: shiny>] +>>> TaggedItem.objects.filter(content_type__pk=ctype.id, object_id=quartz.id) +[<TaggedItem: clearish>] +"""
\ No newline at end of file diff --git a/tests/modeltests/get_or_create/__init__.py b/tests/modeltests/get_or_create/__init__.py new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/tests/modeltests/get_or_create/__init__.py diff --git a/tests/modeltests/get_or_create/models.py b/tests/modeltests/get_or_create/models.py new file mode 100644 index 0000000000..10a8721afc --- /dev/null +++ b/tests/modeltests/get_or_create/models.py @@ -0,0 +1,52 @@ +""" +32. get_or_create() + +get_or_create() does what it says: it tries to look up an object with the given +parameters. If an object isn't found, it creates one with the given parameters. +""" + +from django.db import models + +class Person(models.Model): + first_name = models.CharField(maxlength=100) + last_name = models.CharField(maxlength=100) + birthday = models.DateField() + + def __str__(self): + return '%s %s' % (self.first_name, self.last_name) + +API_TESTS = """ +# Acting as a divine being, create an Person. +>>> from datetime import date +>>> p = Person(first_name='John', last_name='Lennon', birthday=date(1940, 10, 9)) +>>> p.save() + +# Only one Person is in the database at this point. +>>> Person.objects.count() +1 + +# get_or_create() a person with similar first names. +>>> p, created = Person.objects.get_or_create(first_name='John', last_name='Lennon', defaults={'birthday': date(1940, 10, 9)}) + +# get_or_create() didn't have to create an object. +>>> created +False + +# There's still only one Person in the database. +>>> Person.objects.count() +1 + +# get_or_create() a Person with a different name. +>>> p, created = Person.objects.get_or_create(first_name='George', last_name='Harrison', defaults={'birthday': date(1943, 2, 25)}) +>>> created +True +>>> Person.objects.count() +2 + +# If we execute the exact same statement, it won't create a Person. +>>> p, created = Person.objects.get_or_create(first_name='George', last_name='Harrison', defaults={'birthday': date(1943, 2, 25)}) +>>> created +False +>>> Person.objects.count() +2 +""" diff --git a/tests/modeltests/invalid_models/models.py b/tests/modeltests/invalid_models/models.py index 127cc9e0d2..1720dd96d3 100644 --- a/tests/modeltests/invalid_models/models.py +++ b/tests/modeltests/invalid_models/models.py @@ -74,7 +74,7 @@ invalid_models.fielderrors: "floatfield": FloatFields require a "decimal_places" invalid_models.fielderrors: "floatfield": FloatFields require a "max_digits" attribute. invalid_models.fielderrors: "filefield": FileFields require an "upload_to" attribute. invalid_models.fielderrors: "prepopulate": prepopulate_from should be a list or tuple. -invalid_models.fielderrors: "choices": "choices" should be either a tuple or list. +invalid_models.fielderrors: "choices": "choices" should be iterable (e.g., a tuple or list). invalid_models.fielderrors: "choices2": "choices" should be a sequence of two-tuples. invalid_models.fielderrors: "choices2": "choices" should be a sequence of two-tuples. invalid_models.fielderrors: "index": "db_index" should be either None, True or False. diff --git a/tests/modeltests/properties/models.py b/tests/modeltests/properties/models.py index e9d8da9594..3b0133bf8a 100644 --- a/tests/modeltests/properties/models.py +++ b/tests/modeltests/properties/models.py @@ -12,8 +12,14 @@ class Person(models.Model): def _get_full_name(self): return "%s %s" % (self.first_name, self.last_name) + + def _set_full_name(self, combined_name): + self.first_name, self.last_name = combined_name.split(' ', 1) + full_name = property(_get_full_name) + full_name_2 = property(_get_full_name, _set_full_name) + API_TESTS = """ >>> a = Person(first_name='John', last_name='Lennon') >>> a.save() @@ -25,4 +31,10 @@ API_TESTS = """ Traceback (most recent call last): ... AttributeError: can't set attribute + +# But "full_name_2" has, and it can be used to initialise the class. +>>> a2 = Person(full_name_2 = 'Paul McCartney') +>>> a2.save() +>>> a2.first_name +'Paul' """ diff --git a/tests/othertests/templates.py b/tests/othertests/templates.py index ed7105bb71..96ad330917 100644 --- a/tests/othertests/templates.py +++ b/tests/othertests/templates.py @@ -169,8 +169,7 @@ TEMPLATE_TESTS = { 'comment-tag05': ("foo{% comment %} {% somerandomtag %} {% endcomment %}", {}, "foo"), ### CYCLE TAG ############################################################# - #'cycleXX': ('', {}, ''), - 'cycle01': ('{% cycle a, %}', {}, 'a'), + 'cycle01': ('{% cycle a %}', {}, template.TemplateSyntaxError), 'cycle02': ('{% cycle a,b,c as abc %}{% cycle abc %}', {}, 'ab'), 'cycle03': ('{% cycle a,b,c as abc %}{% cycle abc %}{% cycle abc %}', {}, 'abc'), 'cycle04': ('{% cycle a,b,c as abc %}{% cycle abc %}{% cycle abc %}{% cycle abc %}', {}, 'abca'), @@ -193,13 +192,11 @@ TEMPLATE_TESTS = { 'exception04': ("{% extends 'inheritance17' %}{% block first %}{% echo 400 %}5678{% endblock %}", {}, template.TemplateSyntaxError), ### FILTER TAG ############################################################ - #'filterXX': ('', {}, ''), 'filter01': ('{% filter upper %}{% endfilter %}', {}, ''), 'filter02': ('{% filter upper %}django{% endfilter %}', {}, 'DJANGO'), 'filter03': ('{% filter upper|lower %}django{% endfilter %}', {}, 'django'), ### FIRSTOF TAG ########################################################### - #'firstofXX': ('', {}, ''), 'firstof01': ('{% firstof a b c %}', {'a':0,'b':0,'c':0}, ''), 'firstof02': ('{% firstof a b c %}', {'a':1,'b':0,'c':0}, '1'), 'firstof03': ('{% firstof a b c %}', {'a':0,'b':2,'c':0}, '2'), @@ -220,8 +217,79 @@ TEMPLATE_TESTS = { 'if-tag02': ("{% if foo %}yes{% else %}no{% endif %}", {"foo": False}, "no"), 'if-tag03': ("{% if foo %}yes{% else %}no{% endif %}", {}, "no"), + # AND + 'if-tag-and01': ("{% if foo and bar %}yes{% else %}no{% endif %}", {'foo': True, 'bar': True}, 'yes'), + 'if-tag-and02': ("{% if foo and bar %}yes{% else %}no{% endif %}", {'foo': True, 'bar': False}, 'no'), + 'if-tag-and03': ("{% if foo and bar %}yes{% else %}no{% endif %}", {'foo': False, 'bar': True}, 'no'), + 'if-tag-and04': ("{% if foo and bar %}yes{% else %}no{% endif %}", {'foo': False, 'bar': False}, 'no'), + 'if-tag-and05': ("{% if foo and bar %}yes{% else %}no{% endif %}", {'foo': False}, 'no'), + 'if-tag-and06': ("{% if foo and bar %}yes{% else %}no{% endif %}", {'bar': False}, 'no'), + 'if-tag-and07': ("{% if foo and bar %}yes{% else %}no{% endif %}", {'foo': True}, 'no'), + 'if-tag-and08': ("{% if foo and bar %}yes{% else %}no{% endif %}", {'bar': True}, 'no'), + + # OR + 'if-tag-or01': ("{% if foo or bar %}yes{% else %}no{% endif %}", {'foo': True, 'bar': True}, 'yes'), + 'if-tag-or02': ("{% if foo or bar %}yes{% else %}no{% endif %}", {'foo': True, 'bar': False}, 'yes'), + 'if-tag-or03': ("{% if foo or bar %}yes{% else %}no{% endif %}", {'foo': False, 'bar': True}, 'yes'), + 'if-tag-or04': ("{% if foo or bar %}yes{% else %}no{% endif %}", {'foo': False, 'bar': False}, 'no'), + 'if-tag-or05': ("{% if foo or bar %}yes{% else %}no{% endif %}", {'foo': False}, 'no'), + 'if-tag-or06': ("{% if foo or bar %}yes{% else %}no{% endif %}", {'bar': False}, 'no'), + 'if-tag-or07': ("{% if foo or bar %}yes{% else %}no{% endif %}", {'foo': True}, 'yes'), + 'if-tag-or08': ("{% if foo or bar %}yes{% else %}no{% endif %}", {'bar': True}, 'yes'), + + # TODO: multiple ORs + + # NOT + 'if-tag-not01': ("{% if not foo %}no{% else %}yes{% endif %}", {'foo': True}, 'yes'), + 'if-tag-not02': ("{% if not %}yes{% else %}no{% endif %}", {'foo': True}, 'no'), + 'if-tag-not03': ("{% if not %}yes{% else %}no{% endif %}", {'not': True}, 'yes'), + 'if-tag-not04': ("{% if not not %}no{% else %}yes{% endif %}", {'not': True}, 'yes'), + 'if-tag-not05': ("{% if not not %}no{% else %}yes{% endif %}", {}, 'no'), + + 'if-tag-not06': ("{% if foo and not bar %}yes{% else %}no{% endif %}", {}, 'no'), + 'if-tag-not07': ("{% if foo and not bar %}yes{% else %}no{% endif %}", {'foo': True, 'bar': True}, 'no'), + 'if-tag-not08': ("{% if foo and not bar %}yes{% else %}no{% endif %}", {'foo': True, 'bar': False}, 'yes'), + 'if-tag-not09': ("{% if foo and not bar %}yes{% else %}no{% endif %}", {'foo': False, 'bar': True}, 'no'), + 'if-tag-not10': ("{% if foo and not bar %}yes{% else %}no{% endif %}", {'foo': False, 'bar': False}, 'no'), + + 'if-tag-not11': ("{% if not foo and bar %}yes{% else %}no{% endif %}", {}, 'no'), + 'if-tag-not12': ("{% if not foo and bar %}yes{% else %}no{% endif %}", {'foo': True, 'bar': True}, 'no'), + 'if-tag-not13': ("{% if not foo and bar %}yes{% else %}no{% endif %}", {'foo': True, 'bar': False}, 'no'), + 'if-tag-not14': ("{% if not foo and bar %}yes{% else %}no{% endif %}", {'foo': False, 'bar': True}, 'yes'), + 'if-tag-not15': ("{% if not foo and bar %}yes{% else %}no{% endif %}", {'foo': False, 'bar': False}, 'no'), + + 'if-tag-not16': ("{% if foo or not bar %}yes{% else %}no{% endif %}", {}, 'yes'), + 'if-tag-not17': ("{% if foo or not bar %}yes{% else %}no{% endif %}", {'foo': True, 'bar': True}, 'yes'), + 'if-tag-not18': ("{% if foo or not bar %}yes{% else %}no{% endif %}", {'foo': True, 'bar': False}, 'yes'), + 'if-tag-not19': ("{% if foo or not bar %}yes{% else %}no{% endif %}", {'foo': False, 'bar': True}, 'no'), + 'if-tag-not20': ("{% if foo or not bar %}yes{% else %}no{% endif %}", {'foo': False, 'bar': False}, 'yes'), + + 'if-tag-not21': ("{% if not foo or bar %}yes{% else %}no{% endif %}", {}, 'yes'), + 'if-tag-not22': ("{% if not foo or bar %}yes{% else %}no{% endif %}", {'foo': True, 'bar': True}, 'yes'), + 'if-tag-not23': ("{% if not foo or bar %}yes{% else %}no{% endif %}", {'foo': True, 'bar': False}, 'no'), + 'if-tag-not24': ("{% if not foo or bar %}yes{% else %}no{% endif %}", {'foo': False, 'bar': True}, 'yes'), + 'if-tag-not25': ("{% if not foo or bar %}yes{% else %}no{% endif %}", {'foo': False, 'bar': False}, 'yes'), + + 'if-tag-not26': ("{% if not foo and not bar %}yes{% else %}no{% endif %}", {}, 'yes'), + 'if-tag-not27': ("{% if not foo and not bar %}yes{% else %}no{% endif %}", {'foo': True, 'bar': True}, 'no'), + 'if-tag-not28': ("{% if not foo and not bar %}yes{% else %}no{% endif %}", {'foo': True, 'bar': False}, 'no'), + 'if-tag-not29': ("{% if not foo and not bar %}yes{% else %}no{% endif %}", {'foo': False, 'bar': True}, 'no'), + 'if-tag-not30': ("{% if not foo and not bar %}yes{% else %}no{% endif %}", {'foo': False, 'bar': False}, 'yes'), + + 'if-tag-not31': ("{% if not foo or not bar %}yes{% else %}no{% endif %}", {}, 'yes'), + 'if-tag-not32': ("{% if not foo or not bar %}yes{% else %}no{% endif %}", {'foo': True, 'bar': True}, 'no'), + 'if-tag-not33': ("{% if not foo or not bar %}yes{% else %}no{% endif %}", {'foo': True, 'bar': False}, 'yes'), + 'if-tag-not34': ("{% if not foo or not bar %}yes{% else %}no{% endif %}", {'foo': False, 'bar': True}, 'yes'), + 'if-tag-not35': ("{% if not foo or not bar %}yes{% else %}no{% endif %}", {'foo': False, 'bar': False}, 'yes'), + + # AND and OR raises a TemplateSyntaxError + 'if-tag-error01': ("{% if foo or bar and baz %}yes{% else %}no{% endif %}", {'foo': False, 'bar': False}, template.TemplateSyntaxError), + 'if-tag-error02': ("{% if foo and %}yes{% else %}no{% endif %}", {'foo': True}, template.TemplateSyntaxError), + 'if-tag-error03': ("{% if foo or %}yes{% else %}no{% endif %}", {'foo': True}, template.TemplateSyntaxError), + 'if-tag-error04': ("{% if not foo and %}yes{% else %}no{% endif %}", {'foo': True}, template.TemplateSyntaxError), + 'if-tag-error05': ("{% if not foo or %}yes{% else %}no{% endif %}", {'foo': True}, template.TemplateSyntaxError), + ### IFCHANGED TAG ######################################################### - #'ifchangedXX': ('', {}, ''), 'ifchanged01': ('{% for n in num %}{% ifchanged %}{{ n }}{% endifchanged %}{% endfor %}', { 'num': (1,2,3) }, '123'), 'ifchanged02': ('{% for n in num %}{% ifchanged %}{{ n }}{% endifchanged %}{% endfor %}', { 'num': (1,1,3) }, '13'), 'ifchanged03': ('{% for n in num %}{% ifchanged %}{{ n }}{% endifchanged %}{% endfor %}', { 'num': (1,1,1) }, '1'), @@ -238,6 +306,18 @@ TEMPLATE_TESTS = { 'ifequal09': ('{% ifequal a "test" %}yes{% else %}no{% endifequal %}', {}, "no"), 'ifequal10': ('{% ifequal a b %}yes{% else %}no{% endifequal %}', {}, "yes"), + # SMART SPLITTING + 'ifequal-split01': ('{% ifequal a "test man" %}yes{% else %}no{% endifequal %}', {}, "no"), + 'ifequal-split02': ('{% ifequal a "test man" %}yes{% else %}no{% endifequal %}', {'a': 'foo'}, "no"), + 'ifequal-split03': ('{% ifequal a "test man" %}yes{% else %}no{% endifequal %}', {'a': 'test man'}, "yes"), + 'ifequal-split04': ("{% ifequal a 'test man' %}yes{% else %}no{% endifequal %}", {'a': 'test man'}, "yes"), + 'ifequal-split05': ("{% ifequal a 'i \"love\" you' %}yes{% else %}no{% endifequal %}", {'a': ''}, "no"), + 'ifequal-split06': ("{% ifequal a 'i \"love\" you' %}yes{% else %}no{% endifequal %}", {'a': 'i "love" you'}, "yes"), + 'ifequal-split07': ("{% ifequal a 'i \"love\" you' %}yes{% else %}no{% endifequal %}", {'a': 'i love you'}, "no"), + 'ifequal-split08': (r"{% ifequal a 'I\'m happy' %}yes{% else %}no{% endifequal %}", {'a': "I'm happy"}, "yes"), + 'ifequal-split09': (r"{% ifequal a 'slash\man' %}yes{% else %}no{% endifequal %}", {'a': r"slash\man"}, "yes"), + 'ifequal-split10': (r"{% ifequal a 'slash\man' %}yes{% else %}no{% endifequal %}", {'a': r"slashman"}, "no"), + ### IFNOTEQUAL TAG ######################################################## 'ifnotequal01': ("{% ifnotequal a b %}yes{% endifnotequal %}", {"a": 1, "b": 2}, "yes"), 'ifnotequal02': ("{% ifnotequal a b %}yes{% endifnotequal %}", {"a": 1, "b": 1}, ""), @@ -388,7 +468,6 @@ TEMPLATE_TESTS = { """), ### REGROUP TAG ########################################################### - #'regroupXX': ('', {}, ''), 'regroup01': ('{% regroup data by bar as grouped %}' + \ '{% for group in grouped %}' + \ '{{ group.grouper }}:' + \ @@ -414,16 +493,18 @@ TEMPLATE_TESTS = { {}, ''), ### TEMPLATETAG TAG ####################################################### - #'templatetagXX': ('', {}, ''), 'templatetag01': ('{% templatetag openblock %}', {}, '{%'), 'templatetag02': ('{% templatetag closeblock %}', {}, '%}'), 'templatetag03': ('{% templatetag openvariable %}', {}, '{{'), 'templatetag04': ('{% templatetag closevariable %}', {}, '}}'), 'templatetag05': ('{% templatetag %}', {}, template.TemplateSyntaxError), 'templatetag06': ('{% templatetag foo %}', {}, template.TemplateSyntaxError), + 'templatetag07': ('{% templatetag openbrace %}', {}, '{'), + 'templatetag08': ('{% templatetag closebrace %}', {}, '}'), + 'templatetag09': ('{% templatetag openbrace %}{% templatetag openbrace %}', {}, '{{'), + 'templatetag10': ('{% templatetag closebrace %}{% templatetag closebrace %}', {}, '}}'), ### WIDTHRATIO TAG ######################################################## - #'widthratioXX': ('', {}, ''), 'widthratio01': ('{% widthratio a b 0 %}', {'a':50,'b':100}, '0'), 'widthratio02': ('{% widthratio a b 100 %}', {'a':0,'b':0}, ''), 'widthratio03': ('{% widthratio a b 100 %}', {'a':0,'b':100}, '0'), @@ -440,11 +521,11 @@ TEMPLATE_TESTS = { 'widthratio08': ('{% widthratio %}', {}, template.TemplateSyntaxError), 'widthratio09': ('{% widthratio a b %}', {'a':50,'b':100}, template.TemplateSyntaxError), 'widthratio10': ('{% widthratio a b 100.0 %}', {'a':50,'b':100}, template.TemplateSyntaxError), - + ### NOW TAG ######################################################## # Simple case 'now01' : ('{% now "j n Y"%}', {}, str(datetime.now().day) + ' ' + str(datetime.now().month) + ' ' + str(datetime.now().year)), - + # Check parsing of escaped and special characters 'now02' : ('{% now "j "n" Y"%}', {}, template.TemplateSyntaxError), # 'now03' : ('{% now "j \"n\" Y"%}', {}, str(datetime.now().day) + '"' + str(datetime.now().month) + '"' + str(datetime.now().year)), diff --git a/tests/runtests.py b/tests/runtests.py index f0eee97ec5..87cad83124 100755 --- a/tests/runtests.py +++ b/tests/runtests.py @@ -21,14 +21,14 @@ def log_error(model_name, title, description): MODEL_TEST_DIR = os.path.join(os.path.dirname(__file__), MODEL_TESTS_DIR_NAME) ALWAYS_INSTALLED_APPS = [ - 'django.contrib.admin', - 'django.contrib.auth', - 'django.contrib.comments', 'django.contrib.contenttypes', + 'django.contrib.auth', + 'django.contrib.sites', 'django.contrib.flatpages', 'django.contrib.redirects', 'django.contrib.sessions', - 'django.contrib.sites', + 'django.contrib.comments', + 'django.contrib.admin', ] def get_test_models(): @@ -148,6 +148,12 @@ class TestRunner: # Initialize the test database. cursor = connection.cursor() + + # Install the core always installed apps + for app in ALWAYS_INSTALLED_APPS: + self.output(1, "Installing contrib app %s" % app) + mod = __import__(app + ".models", '', '', ['']) + management.install(mod) # Run the tests for each test model. self.output(1, "Running app tests") |