Fixed tests so they run under Django 1.7

This commit is contained in:
Brent O'Connor 2014-09-12 13:37:39 -05:00 committed by Corey Oordt
parent 9822ba8cbb
commit 70abc1c807
10 changed files with 15 additions and 14 deletions

View file

@ -27,7 +27,7 @@ class Command(BaseCommand):
else:
return ' ' * indent_amt
@transaction.commit_on_success
@transaction.atomic
def make_category(self, string, parent=None, order=1):
"""
Make and save a category object from a string

View file

@ -1,5 +1,5 @@
{% load category_tags %}{% spaceless %}
<ul><li><a href="{% url categories_tree_list %}">Top</a>
<ul><li><a href="{% url 'categories_tree_list' %}">Top</a>
{% for node,structure in path|tree_info %}
{% if structure.new_level %}<ul><li>
{% else %}</li><li>

View file

@ -1,6 +1,2 @@
from categories.tests.category_import import *
from categories.tests.templatetags import *
from categories.tests.manager import *
from categories.tests.registration import *
__fixtures__ = ['categories.json']

View file

@ -1,5 +1,6 @@
from django.test import TestCase
from django import template
import re
from categories.models import Category
@ -29,12 +30,14 @@ class CategoryTagsTest(TestCase):
# display_path_as_ul
rock_resp = u'<ul><li><a href="/categories/">Top</a></li></ul>'
resp = self.render_template('{% load category_tags %}{% display_path_as_ul "/Rock" %}')
resp = re.sub(r'\n$', "", resp)
self.assertEqual(resp, rock_resp)
# display_drilldown_as_ul
expected_resp = u'<ul><li><a href="/categories/">Top</a><ul><li><a href="/categories/world/">World</a><ul><li><strong>Worldbeat</strong><ul><li><a href="/categories/world/worldbeat/afrobeat/">Afrobeat</a></li></ul></li></ul></li></ul></li></ul>'
resp = self.render_template('{% load category_tags %}'
'{% display_drilldown_as_ul "/World/Worldbeat" "categories.category" %}')
resp = re.sub(r'\n$', "", resp)
self.assertEqual(resp, expected_resp)
# breadcrumbs

View file

@ -1,11 +1,10 @@
#!/usr/bin/env python
from django.core.management import execute_manager
try:
import settings # Assumed to be in the same directory.
except ImportError:
import sys
sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run django-admin.py, passing it your settings module.\n(If the file settings.py does indeed exist, it's causing an ImportError somehow.)\n" % __file__)
sys.exit(1)
import os
import sys
if __name__ == "__main__":
execute_manager(settings)
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "example.settings")
from django.core.management import execute_from_command_line
execute_from_command_line(sys.argv)

View file

@ -123,6 +123,8 @@ CATEGORIES_SETTINGS = {
},
}
TEST_RUNNER = 'django.test.runner.DiscoverRunner'
if django.VERSION[1] >= 4:
from settings14 import *
if django.VERSION[1] == 3:

View file

@ -14,6 +14,7 @@ class SimpleTextAdmin(admin.ModelAdmin):
class SimpleCategoryAdminForm(CategoryBaseAdminForm):
class Meta:
model = SimpleCategory
fields = '__all__'
class SimpleCategoryAdmin(CategoryBaseAdmin):
form = SimpleCategoryAdminForm