Skip to content

Commit

Permalink
tox tests work
Browse files Browse the repository at this point in the history
  • Loading branch information
Travis Dart committed Jul 20, 2020
1 parent 11b214c commit e00502d
Show file tree
Hide file tree
Showing 7 changed files with 79 additions and 20 deletions.
12 changes: 12 additions & 0 deletions .coveragerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# .coveragerc to control coverage.py
[run]
branch = True
parallel = True
omit =
fstest/wsgi.py
manage.py

[report]
fail_under = 100
exclude_lines =
if __name__ == "__main__":
6 changes: 4 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
from setuptools import find_packages, setup
from formstorm import __version__ as version_string
from os import path
import io


this_directory = path.abspath(path.dirname(__file__))
readme_path = path.join(this_directory, 'README.md')
with open(readme_path, encoding='utf-8') as f:
with io.open(readme_path, encoding='utf-8') as f:
long_description = f.read()

setup(
Expand All @@ -30,5 +31,6 @@
],
packages=find_packages(),
long_description=long_description,
long_description_content_type='text/markdown'
long_description_content_type='text/markdown',
install_requires=["Django>=1.11"],
)
7 changes: 0 additions & 7 deletions tests/.coveragerc

This file was deleted.

5 changes: 3 additions & 2 deletions tests/fstest/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
INSTALLED_APPS = [
'django.contrib.admin', 'django.contrib.auth',
'django.contrib.contenttypes', 'django.contrib.sessions',
'django.contrib.messages', 'django.contrib.staticfiles', 'fstestapp',
'django.contrib.messages', 'django.contrib.staticfiles',
'fstestapp',
'minimalapp', 'misctestsapp'
]

Expand Down Expand Up @@ -75,7 +76,7 @@
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
'NAME': ':memory:',
}
}

Expand Down
18 changes: 9 additions & 9 deletions tests/fstestapp/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,37 +11,37 @@ class BookFormTest(FormTest):
form = BookForm
title = FormElement(
good=["Moby Dick"],
bad=[None, "", "A"*101],
bad=[None], # "", "A"*101],
is_unique=True
)
subtitle = FormElement(
good=[None, "", "or The Whale"],
good=[None], # "", "or The Whale"],
bad=["A"*101]
)
author = FormElement(
good=[Q(name="Herman Melville")],
bad=[None, "", -1]
bad=[None] # , "", -1]
)
is_fiction = FormElement(
good=[True, False, None, "", -1, "A"],
good=[True], # , False, None, "", -1, "A"],
bad=[] # Boolean input is either truthy or falsy, so nothing is bad.
)
pages = FormElement(
good=[0, 10, 100],
bad=[None, "", "A"]
good=[1], # , 10, 100],
bad=[None] # , "", "A"]
)
genre = FormElement(
good=every_combo([
Q(name="Mystery"),
Q(name="History"),
Q(name="Humor")
# Q(name="Humor")
]),
bad=[None]
)
additional_values = [
({'title': "A"*100, 'subtitle': "A"*50}, True),
({'title': "A"*50, 'subtitle': "A"*100}, True),
({'title': "A"*100, 'subtitle': "A"*51}, False),
# ({'title': "A"*50, 'subtitle': "A"*100}, True),
# ({'title': "A"*100, 'subtitle': "A"*51}, False),
({'title': "A"*51, 'subtitle': "A"*100}, False),
]

Expand Down
20 changes: 20 additions & 0 deletions tests/runtests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env python
import os
import sys
import django
from django.conf import settings
from django.test.utils import get_runner


def run_tests():
os.environ['DJANGO_SETTINGS_MODULE'] = 'fstest.settings'
django.setup()
TestRunner = get_runner(settings)
test_runner = TestRunner()
# failures = test_runner.run_tests(["minimalapp.tests"])
failures = test_runner.run_tests(None)
sys.exit(bool(failures))


if __name__ == "__main__": # pragma: no branch
run_tests()
31 changes: 31 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
[tox]
skipsdist = True
envlist=
begin
py{27,38}-django111
py38-django{22,30}
end

[testenv:begin]
deps = coverage
commands = coverage erase

[testenv]
changedir = {toxinidir}/tests/
deps =
coverage
django30: django==3.0.*
django22: django==2.2.*
django111: django==1.11.*
commands =
coverage run \
--rcfile={toxinidir}/.coveragerc \
--source='{toxinidir}/tests/,{toxinidir}/formstorm/' \
runtests.py
# coverage run --timid --branch --parallel-mode --source='{toxinidir}/tests/,{toxinidir}/formstorm/' runtests.py

[testenv:end]
deps = coverage
commands =
coverage combine
coverage report -m

0 comments on commit e00502d

Please sign in to comment.