Skip to content

Commit

Permalink
Merge pull request #5 from gyst/master
Browse files Browse the repository at this point in the history
 Reorganize tests to make functional tests discoverable
  • Loading branch information
janwijbrand committed Jan 12, 2018
2 parents cbf7d87 + d37650f commit 0926d38
Show file tree
Hide file tree
Showing 29 changed files with 79 additions and 16 deletions.
10 changes: 7 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
__pycache__
.coverage
*.pyc
.coverage*
.installed.cfg
.mr.developer.cfg
.tox
*.pyc
__pycache__
bin
dev
develop-eggs
htmlcov/
lib/
parts
pip-selfcheck.json
pyvenv.cfg
src/*.egg-info
4 changes: 2 additions & 2 deletions buildout.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ grokcore.formlib =
[interpreter]
recipe = zc.recipe.egg
eggs = grokcore.formlib
interpreter = python
interpreter = py

[test]
recipe = zc.recipe.testrunner
eggs = grokcore.formlib
grokcore.formlib[test]
defaults = ['--tests-pattern', '^f?tests$', '-v']
defaults = ['-vc']
4 changes: 4 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# NOTE: setuptools and zc.buildout versions must be in sync with:
# ztk-versions.cfg
setuptools==38.2.4
zc.buildout==2.10.0
2 changes: 1 addition & 1 deletion src/grokcore/formlib/ftesting.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<grok:grok package="grokcore.formlib.testing" />

<include package="grokcore.formlib" />
<grok:grok package="grokcore.formlib.ftests" />
<grok:grok package="grokcore.formlib.tests.functional" />

<browser:defaultView
for="grokcore.component.interfaces.IContext"
Expand Down
30 changes: 29 additions & 1 deletion src/grokcore/formlib/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,29 @@
# make this directory a package
##############################################################################
#
# Copyright (c) 2006-2007 Zope Foundation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""Grok
"""
from grokcore.component import *
from grokcore.security import *
from grokcore.view import *

from grokcore.formlib.components import Form, AddForm, EditForm, DisplayForm
from grokcore.formlib.formlib import action, AutoFields, Fields

# Import this module so that it's available as soon as you import the
# 'grokcore.formlib' package. Useful for tests and interpreter examples.
import grokcore.formlib.testing

# Our __init__ provides the grok API directly so using 'import grok' is enough.
from grokcore.formlib.interfaces import IGrokcoreFormlibAPI
__all__ = list(IGrokcoreFormlibAPI)
1 change: 1 addition & 0 deletions src/grokcore/formlib/tests/base/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# make this directory a package
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
Traceback (most recent call last):
...
martian.error.GrokError: It is not allowed to specify a custom 'render' \
method for form <class 'grokcore.formlib.tests.form.norender.Edit'>. \
method for form <class 'grokcore.formlib.tests.base.form.norender.Edit'>. \
Forms either use the default template or a custom-supplied one.
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
Traceback (most recent call last):
...
martian.error.GrokError: It is not allowed to specify a custom 'render' \
method for form <class 'grokcore.formlib.tests.form.norender2.Edit'>. \
method for form <class 'grokcore.formlib.tests.base.form.norender2.Edit'>. \
Forms either use the default template or a custom-supplied one.
"""
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
Traceback (most recent call last):
...
zope.publisher.interfaces.http.MethodNotAllowed: \
<grokcore.formlib.ftests.form.form.Mammoth object at ...>, \
<grokcore.formlib.tests.functional.form.form.Mammoth object at ...>, \
<zope.publisher.browser.BrowserRequest instance \
URL=http://localhost/manfred/@@editprotected>
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ def cleanUpZope(test):


def suiteFromPackage(name):
files = resource_listdir(__name__, name)
layer_dir = 'base'
files = resource_listdir(__name__, '{}/{}'.format(layer_dir, name))
suite = unittest.TestSuite()
for filename in files:
if not filename.endswith('.py'):
Expand All @@ -34,7 +35,8 @@ def suiteFromPackage(name):
continue
if filename == '__init__.py':
continue
dottedname = 'grokcore.formlib.tests.%s.%s' % (name, filename[:-3])
dottedname = 'grokcore.formlib.tests.%s.%s.%s' % (
layer_dir, name, filename[:-3])
test = doctest.DocTestSuite(
dottedname,
setUp=setUpZope,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,16 @@ class Layer(


def suiteFromPackage(name):
files = resource_listdir(__name__, name)
layer_dir = 'functional'
files = resource_listdir(__name__, '{}/{}'.format(layer_dir, name))
suite = unittest.TestSuite()
for filename in files:
if not filename.endswith('.py'):
continue
if filename == '__init__.py':
continue
dottedname = 'grokcore.formlib.ftests.%s.%s' % (name, filename[:-3])
dottedname = 'grokcore.formlib.tests.%s.%s.%s' % (
layer_dir, name, filename[:-3])
test = doctest.DocTestSuite(
dottedname,
checker=checker,
Expand Down
26 changes: 24 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,16 +1,38 @@
[tox]
envlist =
coverage-clean,
py27,
py34,
py35,
py36,
pypy,
pypy3
pypy3,
coverage-report

[testenv]
commands =
coverage run -m zope.testrunner --test-path=src {posargs:-vc}
coverage run --source=grokcore.formlib -m zope.testrunner --test-path=src {posargs:-vc}
setenv =
COVERAGE_FILE=.coverage.{envname}
deps =
.[test]
zope.testrunner
coverage

[testenv:coverage-clean]
deps = coverage
setenv =
COVERAGE_FILE=.coverage
skip_install = true
commands = coverage erase

[testenv:coverage-report]
deps = coverage
setenv =
COVERAGE_FILE=.coverage
skip_install = true
commands =
coverage combine
coverage report
coverage html
coverage

0 comments on commit 0926d38

Please sign in to comment.