From 842e08cf2e89b66180892ce38b24fa72ffda39c2 Mon Sep 17 00:00:00 2001 From: Jannis Leidel Date: Mon, 7 May 2012 14:06:54 +0200 Subject: [PATCH] Switched to using nose and django-nose for easy test running. --- .gitignore | 4 +--- .travis.yml | 3 ++- INSTALL | 17 ----------------- dbtemplates/admin.py | 2 +- .../commands/check_template_syntax.py | 1 + .../management/commands/sync_templates.py | 4 +++- dbtemplates/{tests.py => test_cases.py} | 4 ++-- dbtemplates/test_settings.py | 9 ++------- dbtemplates/utils/template.py | 8 +++----- requirements/tests.txt | 6 ++---- setup.cfg | 4 ++++ 11 files changed, 21 insertions(+), 41 deletions(-) delete mode 100644 INSTALL rename dbtemplates/{tests.py => test_cases.py} (98%) diff --git a/.gitignore b/.gitignore index 993468d..9d5809f 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,4 @@ example/example.db docs/_build .tox/ *.egg/ -pep8.txt -coverage.xml -reports/ \ No newline at end of file +.coverage diff --git a/.travis.yml b/.travis.yml index 1803e05..6ffd9af 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 diff --git a/INSTALL b/INSTALL deleted file mode 100644 index 2e5bc7d..0000000 --- a/INSTALL +++ /dev/null @@ -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/ \ No newline at end of file diff --git a/dbtemplates/admin.py b/dbtemplates/admin.py index 7e4dae8..9505d26 100644 --- a/dbtemplates/admin.py +++ b/dbtemplates/admin.py @@ -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): diff --git a/dbtemplates/management/commands/check_template_syntax.py b/dbtemplates/management/commands/check_template_syntax.py index 16d4ca2..214f531 100644 --- a/dbtemplates/management/commands/check_template_syntax.py +++ b/dbtemplates/management/commands/check_template_syntax.py @@ -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." diff --git a/dbtemplates/management/commands/sync_templates.py b/dbtemplates/management/commands/sync_templates.py index 8c1be09..cffa7db 100644 --- a/dbtemplates/management/commands/sync_templates.py +++ b/dbtemplates/management/commands/sync_templates.py @@ -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() diff --git a/dbtemplates/tests.py b/dbtemplates/test_cases.py similarity index 98% rename from dbtemplates/tests.py rename to dbtemplates/test_cases.py index 7747291..42b2a31 100644 --- a/dbtemplates/tests.py +++ b/dbtemplates/test_cases.py @@ -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') diff --git a/dbtemplates/test_settings.py b/dbtemplates/test_settings.py index b382f07..6ce4617 100644 --- a/dbtemplates/test_settings.py +++ b/dbtemplates/test_settings.py @@ -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' diff --git a/dbtemplates/utils/template.py b/dbtemplates/utils/template.py index 2113237..679a7d9 100644 --- a/dbtemplates/utils/template.py +++ b/dbtemplates/utils/template.py @@ -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 diff --git a/requirements/tests.txt b/requirements/tests.txt index 1a70548..06f0477 100644 --- a/requirements/tests.txt +++ b/requirements/tests.txt @@ -1,5 +1,3 @@ -pep8 -pyflakes -django-jenkins +flake8 +dajngo-nose coverage -pylint \ No newline at end of file diff --git a/setup.cfg b/setup.cfg index cf6fb59..78ce9b8 100644 --- a/setup.cfg +++ b/setup.cfg @@ -11,3 +11,7 @@ upload-dir = docs/_build/html [upload_sphinx] upload-dir = docs/_build/html + +[nosetests] +with-coverage=1 +cover-package=dbtemplates