Skip to content

Commit

Permalink
Reorganize tests to make functional tests discoverable
Browse files Browse the repository at this point in the history
  • Loading branch information
gyst committed Jan 12, 2018
1 parent 04bd74a commit 723882b
Show file tree
Hide file tree
Showing 26 changed files with 46 additions and 12 deletions.
7 changes: 4 additions & 3 deletions .gitignore
@@ -1,11 +1,12 @@
__pycache__
.coverage
*.pyc
.coverage*
.installed.cfg
.mr.developer.cfg
.tox
*.pyc
__pycache__
bin
dev
develop-eggs
htmlcov/
parts
src/*.egg-info
2 changes: 1 addition & 1 deletion src/grokcore/formlib/ftesting.zcml
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
@@ -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
@@ -0,0 +1 @@
# make this directory a package
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
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.
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.
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
Expand Up @@ -25,14 +25,16 @@ class Layer(


def suiteFromPackage(name):
files = resource_listdir(__name__, name)
suite = unittest.TestSuite()
layer_dir = 'functional'
files = resource_listdir(__name__, '{}/{}'.format(layer_dir, name))
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

0 comments on commit 723882b

Please sign in to comment.