Switched to using nose and django-nose for easy test running.

This commit is contained in:
Jannis Leidel 2012-05-07 14:06:54 +02:00
parent 2e430d5370
commit 842e08cf2e
11 changed files with 21 additions and 41 deletions

4
.gitignore vendored
View file

@ -8,6 +8,4 @@ example/example.db
docs/_build
.tox/
*.egg/
pep8.txt
coverage.xml
reports/
.coverage

View file

@ -9,8 +9,9 @@ install:
before_script:
- export PIP_USE_MIRRORS=true
- export DJANGO_SETTINGS_MODULE=dbtemplates.test_settings
- flake8
script:
- django-admin.py jenkins dbtemplates
- django-admin.py test dbtemplates
env:
- DJANGO=1.3.1
- DJANGO=1.4

17
INSTALL
View file

@ -1,17 +0,0 @@
To install it, run the following command inside this directory:
python setup.py install
Or if you'd prefer you can simply place the included ``dbtemplates``
directory somewhere on your Python path, or symlink to it from
somewhere on your Python path; this is useful if you're working from a
Subversion checkout. Since ``dbtemplates`` is registered in the
Python Package Index you can also run ``easy_install django-dbtemplates``
or ``pip install django-dbtemplates`` optionally.
Note that this application requires Python 2.3 or later, and a recent
Subversion checkout of Django. You can obtain Python from
http://www.python.org/ and Django from http://www.djangoproject.com/.
This install notice was bluntly stolen from James Bennett's registration
package, http://www.bitbucket.org/ubernostrum/django-registration/

View file

@ -15,7 +15,7 @@ from dbtemplates.utils.template import check_template_syntax
if settings.DBTEMPLATES_USE_REVERSION:
from reversion.admin import VersionAdmin as TemplateModelAdmin
else:
from django.contrib.admin import ModelAdmin as TemplateModelAdmin
from django.contrib.admin import ModelAdmin as TemplateModelAdmin # noqa
class CodeMirrorTextArea(forms.Textarea):

View file

@ -3,6 +3,7 @@ from django.core.management.base import CommandError, NoArgsCommand
from dbtemplates.models import Template
from dbtemplates.utils.template import check_template_syntax
class Command(NoArgsCommand):
help = "Ensures templates stored in the database don't have syntax errors."

View file

@ -11,6 +11,7 @@ from dbtemplates.models import Template
ALWAYS_ASK, FILES_TO_DATABASE, DATABASE_TO_FILES = ('0', '1', '2')
class Command(NoArgsCommand):
help = "Syncs file system templates with the database bidirectionally."
option_list = NoArgsCommand.option_list + (
@ -89,7 +90,8 @@ class Command(NoArgsCommand):
path, t.__repr__()))
else:
confirm = overwrite
if confirm in ('', FILES_TO_DATABASE, DATABASE_TO_FILES):
if confirm in ('', FILES_TO_DATABASE,
DATABASE_TO_FILES):
if confirm == FILES_TO_DATABASE:
t.content = codecs.open(path, 'r').read()
t.save()

View file

@ -143,5 +143,5 @@ class DbTemplatesTestCase(TestCase):
self.assertTrue(check_template_syntax(good_template)[0])
def test_get_cache_name(self):
name = 'name with spaces'
self.assertEqual(get_cache_key(name), 'dbtemplates::name-with-spaces::1')
self.assertEqual(get_cache_key('name with spaces'),
'dbtemplates::name-with-spaces::1')

View file

@ -21,7 +21,7 @@ INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'dbtemplates',
'django_jenkins',
'django_nose',
]
TEMPLATE_LOADERS = (
@ -30,9 +30,4 @@ TEMPLATE_LOADERS = (
'dbtemplates.loader.Loader',
)
JENKINS_TASKS = (
'django_jenkins.tasks.run_pyflakes',
'django_jenkins.tasks.run_pep8',
'django_jenkins.tasks.with_coverage',
'django_jenkins.tasks.django_tests',
)
TEST_RUNNER = 'django_nose.NoseTestSuiteRunner'

View file

@ -8,13 +8,11 @@ def get_loaders():
from django.template.loader import template_source_loaders
if template_source_loaders is None:
try:
from django.template.loader import (
find_template as finder_func)
from django.template.loader import find_template as finder
except ImportError:
from django.template.loader import (
find_template_source as finder_func)
from django.template.loader import find_template_source as finder # noqa
try:
source, name = finder_func('test')
source, name = finder('test')
except TemplateDoesNotExist:
pass
from django.template.loader import template_source_loaders

View file

@ -1,5 +1,3 @@
pep8
pyflakes
django-jenkins
flake8
dajngo-nose
coverage
pylint

View file

@ -11,3 +11,7 @@ upload-dir = docs/_build/html
[upload_sphinx]
upload-dir = docs/_build/html
[nosetests]
with-coverage=1
cover-package=dbtemplates