Structure of the tests

This commit is contained in:
Pablo Martín 2013-11-26 19:20:19 +01:00
parent 7ced508e25
commit 678bfc089f
6 changed files with 169 additions and 0 deletions

12
.coveragerc Normal file
View File

@ -0,0 +1,12 @@
[run]
source = multiselectfield
omit =
example/*
[report]
exclude_lines =
pragma: no cover
def __repr__
raise NotImplementedError
if __name__ == .__main__.:
def parse_args

15
.travis.yml Normal file
View File

@ -0,0 +1,15 @@
language: python
install:
- pip install -q --use-mirrors tox==1.6.1 coveralls==0.3
script:
- coverage erase
- tox
after_success:
- coverage combine
- coveralls
notifications:
email:
- goinnn@gmail.com

View File

@ -0,0 +1,26 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2013 by Pablo Martín <goinnn@gmail.com>
#
# This software is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This software is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this software. If not, see <http://www.gnu.org/licenses/>.
from django.test import TestCase
from example.app.models import Book
class MultiSelectTestCase(TestCase):
def test_filter(self):
self.assertEqual(Book.objects.filter(tags__contains='sex').count(), 1)
self.assertEqual(Book.objects.filter(tags__contains='boring').count(), 0)

36
example/run_tests.py Normal file
View File

@ -0,0 +1,36 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# Copyright (c) 2013 by Pablo Martín <goinnn@gmail.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this programe. If not, see <http://www.gnu.org/licenses/>.
import os
import sys
import django
from django.conf import ENVIRONMENT_VARIABLE
from django.core import management
if len(sys.argv) == 1:
os.environ[ENVIRONMENT_VARIABLE] = 'example.settings'
else:
os.environ[ENVIRONMENT_VARIABLE] = sys.argv[1]
if django.VERSION[0] == 1 and django.VERSION[1] <= 5:
management.call_command('test', 'app')
else:
management.call_command('test', 'example.app')

View File

@ -0,0 +1,4 @@
from test_project.settings import *
DEBUG = False
TEMPLATE_DEBUG = DEBUG

76
tox.ini Normal file
View File

@ -0,0 +1,76 @@
[tox]
envlist = py27-dj16,py27-dj15,py27-dj14,py33-dj16,py33-dj15,py26-dj16,py26-dj15,py26-dj14
[testenv]
usedevelop = True
commands =
python {envbindir}/coverage run -p example/run_tests.py
python {envbindir}/coverage run -p example/run_tests.py example.settings_no_debug
install_command =
pip install {opts} {packages}
[testenv:py26-dj16]
basepython = python2.6
deps =
django==1.6
pillow==1.7.8
PyYAML==3.10
coveralls==0.3
[testenv:py26-dj15]
basepython = python2.6
deps =
django==1.5.5
pillow==1.7.8
PyYAML==3.10
coveralls==0.3
[testenv:py26-dj14]
basepython = python2.6
deps =
django==1.4.10
pillow==1.7.8
PyYAML==3.10
coveralls==0.3
[testenv:py27-dj16]
basepython = python2.7
deps =
django==1.6
pillow==1.7.8
PyYAML==3.10
coveralls==0.3
[testenv:py27-dj15]
basepython = python2.7
deps =
django==1.5.5
pillow==1.7.8
PyYAML==3.10
coveralls==0.3
[testenv:py27-dj14]
basepython = python2.7
deps =
django==1.4.10
pillow==1.7.8
PyYAML==3.10
coveralls==0.3
[testenv:py33-dj16]
basepython = python3.3
deps =
django==1.6
pillow==2.1.0
PyYAML==3.10
coveralls==0.3
[testenv:py33-dj15]
basepython = python3.3
deps =
django==1.5.5
pillow==2.1.0
PyYAML==3.10
coveralls==0.3