Skip to content

Commit

Permalink
Reorganize tests to make functional discoverable
Browse files Browse the repository at this point in the history
  • Loading branch information
gyst committed Jan 12, 2018
1 parent 51dea47 commit ff2b889
Show file tree
Hide file tree
Showing 24 changed files with 45 additions and 10 deletions.
2 changes: 1 addition & 1 deletion buildout.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,4 @@ recipe = zc.recipe.testrunner
eggs =
grokcore.security
grokcore.security[test]
defaults = ['--tests-pattern', '^f?tests$', '-v']
defaults = ['-vc']
2 changes: 1 addition & 1 deletion src/grokcore/security/ftesting.zcml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
<include package="grokcore.security" file="meta.zcml" />
<include package="grokcore.view" file="publication_security.zcml" />

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

</configure>
32 changes: 31 additions & 1 deletion src/grokcore/security/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,31 @@
# 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.components import Permission
from grokcore.security.components import Public
from grokcore.security.directive import require, permissions

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

# Only export public API
from grokcore.security.interfaces import IGrokcoreSecurityAPI, HAVE_ROLE
if HAVE_ROLE:
from grokcore.security.components import Role

__all__ = list(IGrokcoreSecurityAPI)
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
>>> import grokcore.security.testing
>>>
>>> grokcore.security.testing.grok(
... 'grokcore.security.tests.permissions.directive_fixture')
... 'grokcore.security.tests.base.permissions.directive_fixture')
Traceback (most recent call last):
...
martian.error.GrokImportError: You can only pass unicode values, ASCII \
Expand Down
1 change: 1 addition & 0 deletions src/grokcore/security/tests/base/security/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# make this directory a package
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
...
zope.configuration.config.ConfigurationExecutionError: \
martian.error.GrokError: Undefined permission 'doesnt.exist' in <class \
'grokcore.security.tests.security.missing_permission.MissingPermission'>. \
'grokcore.security.tests.base.security.missing_permission.MissingPermission'>. \
Use grok.Permission first...
"""
import grokcore.security as grok
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
Traceback (most recent call last):
...
martian.error.GrokError: grok.require was called multiple times in \
<class 'grokcore.security.tests.security.multiple_require.MultipleView'>. \
<class 'grokcore.security.tests.base.security.multiple_require.MultipleView'>. \
It may only be set once for a class.
"""
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,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 @@ -29,7 +30,8 @@ def suiteFromPackage(name):
continue
if filename == '__init__.py':
continue
dottedname = 'grokcore.security.tests.%s.%s' % (name, filename[:-3])
dottedname = 'grokcore.security.tests.%s.%s.%s' % (
layer_dir, name, filename[:-3])
test = doctest.DocTestSuite(
dottedname,
tearDown=cleanUpZope,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,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.security.ftests.%s.%s' % (name, filename[:-3])
dottedname = 'grokcore.security.tests.%s.%s.%s' % (
layer_dir, name, filename[:-3])
test = doctest.DocTestSuite(
dottedname,
checker=checker,
Expand Down

0 comments on commit ff2b889

Please sign in to comment.