From 8f269326d5da4ae05fa92ad959f564d1823467c8 Mon Sep 17 00:00:00 2001 From: Florian Friesdorf Date: Mon, 9 Feb 2009 21:08:37 +0100 Subject: [PATCH] PACKAGE_NAME derived from tests.__name__, cleanup --- src/paula/testing/__init__.py | 7 +-- src/paula/testing/config.py | 23 ---------- src/paula/testing/configure.zcml | 9 ---- src/paula/testing/ftesting.zcml | 10 ----- src/paula/testing/globs.py | 5 +-- src/paula/testing/mock.py | 5 +-- src/paula/testing/module.py | 50 ++++++--------------- src/paula/testing/no_package/no_package_file.txt | 1 + src/paula/testing/package/__init__.py | 22 --------- src/paula/testing/package/module.py | 34 +++----------- src/paula/testing/package/subpackage/__init__.py | 22 --------- src/paula/testing/package/subpackage/module.py | 32 +++---------- src/paula/testing/plonetesting.py | 57 ------------------------ src/paula/testing/testing.py | 5 +-- src/paula/testing/tests.py | 49 +++++++------------- src/paula/testing/utils.py | 10 ++--- 16 files changed, 55 insertions(+), 286 deletions(-) delete mode 100644 src/paula/testing/config.py delete mode 100644 src/paula/testing/configure.zcml delete mode 100644 src/paula/testing/ftesting.zcml rewrite src/paula/testing/module.py (73%) rewrite src/paula/testing/package/__init__.py (100%) rewrite src/paula/testing/package/module.py (91%) rewrite src/paula/testing/package/subpackage/__init__.py (100%) rewrite src/paula/testing/package/subpackage/module.py (93%) delete mode 100644 src/paula/testing/plonetesting.py rewrite src/paula/testing/tests.py (66%) diff --git a/src/paula/testing/__init__.py b/src/paula/testing/__init__.py index 6830203..59aa013 100644 --- a/src/paula/testing/__init__.py +++ b/src/paula/testing/__init__.py @@ -1,4 +1,4 @@ -# Copyright (c) 2008 by Florian Friesdorf +# Copyright (c) 2008-2009 by Florian Friesdorf # # GNU Affero General Public License (AGPL) # @@ -15,11 +15,8 @@ # You should have received a copy of the GNU Affero General Public # License along with this program. If not, see # . -""" -""" + __author__ = "Florian Friesdorf " __docformat__ = "plaintext" from paula.testing.testing import get_test_suite -from paula.testing.testing import test_globs -from paula.testing.testing import setUp, tearDown diff --git a/src/paula/testing/config.py b/src/paula/testing/config.py deleted file mode 100644 index ec15c65..0000000 --- a/src/paula/testing/config.py +++ /dev/null @@ -1,23 +0,0 @@ -# Copyright (c) 2008 by Florian Friesdorf -# -# GNU Affero General Public License (AGPL) -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU Affero 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 Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public -# License along with this program. If not, see -# . -""" -""" -__author__ = "Florian Friesdorf " -__docformat__ = "plaintext" - -PACKAGE_NAME="paula.testing" diff --git a/src/paula/testing/configure.zcml b/src/paula/testing/configure.zcml deleted file mode 100644 index e06c9e7..0000000 --- a/src/paula/testing/configure.zcml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - diff --git a/src/paula/testing/ftesting.zcml b/src/paula/testing/ftesting.zcml deleted file mode 100644 index 042a087..0000000 --- a/src/paula/testing/ftesting.zcml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - diff --git a/src/paula/testing/globs.py b/src/paula/testing/globs.py index 3854635..70a36da 100644 --- a/src/paula/testing/globs.py +++ b/src/paula/testing/globs.py @@ -1,4 +1,4 @@ -# Copyright (c) 2008 by Florian Friesdorf +# Copyright (c) 2008-2009 by Florian Friesdorf # # GNU Affero General Public License (AGPL) # @@ -15,8 +15,7 @@ # You should have received a copy of the GNU Affero General Public # License along with this program. If not, see # . -""" -""" + __author__ = "Florian Friesdorf " __docformat__ = "plaintext" diff --git a/src/paula/testing/mock.py b/src/paula/testing/mock.py index 9ab54ed..ee83520 100644 --- a/src/paula/testing/mock.py +++ b/src/paula/testing/mock.py @@ -1,4 +1,4 @@ -# Copyright (c) 2008 by Florian Friesdorf +# Copyright (c) 2008-2009 by Florian Friesdorf # # GNU Affero General Public License (AGPL) # @@ -15,8 +15,7 @@ # You should have received a copy of the GNU Affero General Public # License along with this program. If not, see # . -""" -""" + __author__ = "Florian Friesdorf " __docformat__ = "plaintext" diff --git a/src/paula/testing/module.py b/src/paula/testing/module.py dissimilarity index 73% index 8d1ba0e..d70f3a7 100644 --- a/src/paula/testing/module.py +++ b/src/paula/testing/module.py @@ -1,36 +1,14 @@ -# Copyright (c) 2008 by Florian Friesdorf -# -# GNU Affero General Public License (AGPL) -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU Affero 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 Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public -# License along with this program. If not, see -# . -""" -""" -__author__ = "Florian Friesdorf " -__docformat__ = "plaintext" - -from zope.interface import implements, Interface - -class ISomeObjectUtility(Interface): - pass - -class SomeObject(object): - """ - This is an example test, that just should be found by paula.testing - - >>> 1 + 1 - 2 - """ - implements(ISomeObjectUtility) - name = 'some object utility' +from zope.interface import implements, Interface + +class ISomeObjectUtility(Interface): + pass + +class SomeObject(object): + """ + This is an example test, that just should be found by paula.testing + + >>> 1 + 1 + 2 + """ + implements(ISomeObjectUtility) + name = 'some object utility' diff --git a/src/paula/testing/no_package/no_package_file.txt b/src/paula/testing/no_package/no_package_file.txt index 5abf3fd..e37841d 100644 --- a/src/paula/testing/no_package/no_package_file.txt +++ b/src/paula/testing/no_package/no_package_file.txt @@ -1,3 +1,4 @@ +Failing test >>> True False diff --git a/src/paula/testing/package/__init__.py b/src/paula/testing/package/__init__.py dissimilarity index 100% index d7e97a9..e69de29 100644 --- a/src/paula/testing/package/__init__.py +++ b/src/paula/testing/package/__init__.py @@ -1,22 +0,0 @@ -# Copyright (c) 2008 by Florian Friesdorf -# -# GNU Affero General Public License (AGPL) -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU Affero 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 Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public -# License along with this program. If not, see -# . -""" -""" -__author__ = "Florian Friesdorf " -__docformat__ = "plaintext" - diff --git a/src/paula/testing/package/module.py b/src/paula/testing/package/module.py dissimilarity index 91% index cafdfe5..3d0d12c 100644 --- a/src/paula/testing/package/module.py +++ b/src/paula/testing/package/module.py @@ -1,28 +1,6 @@ -# Copyright (c) 2008 by Florian Friesdorf -# -# GNU Affero General Public License (AGPL) -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU Affero 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 Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public -# License along with this program. If not, see -# . -""" -""" -__author__ = "Florian Friesdorf " -__docformat__ = "plaintext" - -def testfunc(): - """ - >>> 3 + 3 - 6 - """ - return True +def testfunc(): + """ + >>> 3 + 3 + 6 + """ + return True diff --git a/src/paula/testing/package/subpackage/__init__.py b/src/paula/testing/package/subpackage/__init__.py dissimilarity index 100% index d7e97a9..e69de29 100644 --- a/src/paula/testing/package/subpackage/__init__.py +++ b/src/paula/testing/package/subpackage/__init__.py @@ -1,22 +0,0 @@ -# Copyright (c) 2008 by Florian Friesdorf -# -# GNU Affero General Public License (AGPL) -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU Affero 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 Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public -# License along with this program. If not, see -# . -""" -""" -__author__ = "Florian Friesdorf " -__docformat__ = "plaintext" - diff --git a/src/paula/testing/package/subpackage/module.py b/src/paula/testing/package/subpackage/module.py dissimilarity index 93% index a3d24d7..727c8a1 100644 --- a/src/paula/testing/package/subpackage/module.py +++ b/src/paula/testing/package/subpackage/module.py @@ -1,27 +1,5 @@ -# Copyright (c) 2008 by Florian Friesdorf -# -# GNU Affero General Public License (AGPL) -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU Affero 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 Affero General Public License for more details. -# -# You should have received a copy of the GNU Affero General Public -# License along with this program. If not, see -# . -""" -""" -__author__ = "Florian Friesdorf " -__docformat__ = "plaintext" - -def test(): - """ - >>> 2 + 3 - 5 - """ +def test(): + """ + >>> 2 + 3 + 5 + """ diff --git a/src/paula/testing/plonetesting.py b/src/paula/testing/plonetesting.py deleted file mode 100644 index 55b836d..0000000 --- a/src/paula/testing/plonetesting.py +++ /dev/null @@ -1,57 +0,0 @@ -from Products.Five import zcml -from Products.Five import fiveconfigure - -from Testing import ZopeTestCase as ztc - -from Products.PloneTestCase import PloneTestCase as ptc -from Products.PloneTestCase.layer import onsetup, PloneSite -from Products.PloneTestCase.PloneTestCase import setupPloneSite - -from plone.app.controlpanel.tests import ControlPanelTestCase -from kss.core.tests.base import KSSLayer, KSSViewTestCase - -from paula.testing.testing import my_import - -@onsetup -def setup_package(pkg_name, deps=[]): - """ - The @onsetup decorator causes the execution of this body to be deferred - until the setup of the Plone site testing layer. - """ - - # Load the ZCML configuration for the optilux.policy package. - # This includes the other products below as well. - - fiveconfigure.debug_mode = True - - mod = my_import(pkg_name) - zcml.load_config('ftesting.zcml', mod) - fiveconfigure.debug_mode = False - - # We need to tell the testing framework that these products - # should be available. This can't happen until after we have loaded - # the ZCML. - - ztc.installPackage(pkg_name) - for x in deps: - ztc.installPackage(x) - -class PloneTestCase(ptc.PloneTestCase): - """Base class used for test cases - """ - -class FunctionalTestCase(ptc.FunctionalTestCase): - """Test case class used for functional (doc-)tests - """ - -class PanelTestCase(FunctionalTestCase, ControlPanelTestCase): - """Test case used for the control panel tests, with some convenience - methods from plone.app.controlpanel. - """ - -class KSSTestCase(FunctionalTestCase, KSSViewTestCase): - """Test case used for KSS tests - """ - - class layer(KSSLayer, PloneSite): - pass diff --git a/src/paula/testing/testing.py b/src/paula/testing/testing.py index b2ed29b..22eb547 100644 --- a/src/paula/testing/testing.py +++ b/src/paula/testing/testing.py @@ -1,4 +1,4 @@ -# Copyright (c) 2008 by Florian Friesdorf +# Copyright (c) 2008-2009 by Florian Friesdorf # # GNU Affero General Public License (AGPL) # @@ -15,8 +15,7 @@ # You should have received a copy of the GNU Affero General Public # License along with this program. If not, see # . -""" -""" + __author__ = "Florian Friesdorf " __docformat__ = "plaintext" diff --git a/src/paula/testing/tests.py b/src/paula/testing/tests.py dissimilarity index 66% index 47d71e3..7b53749 100644 --- a/src/paula/testing/tests.py +++ b/src/paula/testing/tests.py @@ -1,32 +1,17 @@ -# paula.testing.tests.py -# -# You can simply copy this file to your package and adjust it to your needs -# -# pt.FunctionalDocFileSuite will load your package's ftesting.zcml and -# otherwise setup the same globs as pt.setUp - have a look at __init__.py -""" -""" - -import unittest -from zope.testing import doctestunit -#from zope.component.testing import setUp - -from paula.testing import get_test_suite -from paula.testing import setUp, tearDown - -# XXX: this could be derived from __name__, but then it would not work, -# if being called as __main__ (see bottom) - is that needed? -# eventually we could then derive it from path?! -from config import PACKAGE_NAME - -# File to test, relative to the package root -# all .py files are found -# all .txt files with corresponding .py file are found -files = [ - 'README.txt' - ] - -test_suite = get_test_suite(PACKAGE_NAME, files) - -if __name__ == '__main__': - unittest.main(defaultTest='test_suite') +# paula.testing.tests.py +# +# You can simply copy this file to your package and adjust it to your needs + +from paula.testing import get_test_suite + +# File to test, relative to the package root +# all .py files are found +# all .txt files with corresponding .py file are found +files = [ + 'README.txt' + ] + +# We assume that this modules is in the root of your package +pkgname = __name__[:-6] + +test_suite = get_test_suite(pkgname, files) diff --git a/src/paula/testing/utils.py b/src/paula/testing/utils.py index 1e2da02..c420df4 100644 --- a/src/paula/testing/utils.py +++ b/src/paula/testing/utils.py @@ -1,4 +1,4 @@ -# Copyright (c) 2008 by Florian Friesdorf +# Copyright (c) 2008-2009 by Florian Friesdorf # # GNU Affero General Public License (AGPL) # @@ -15,13 +15,11 @@ # You should have received a copy of the GNU Affero General Public # License along with this program. If not, see # . -""" -""" + __author__ = "Florian Friesdorf " __docformat__ = "plaintext" import os -from paula.testing.interact import interact def hasdoctests(file): """Check whether a file has doctests @@ -70,12 +68,12 @@ def recursedir(path, cond=lambda x: True, filefilter=lambda x: True): >>> l1 = recursedir(pkgpath(pkg)) >>> l1 = filter(lambda x: not x.endswith('.swp'), l1) >>> len(l1) - 37 + 32 >>> l2 = recursedir(pkgpath(pkg), cond=ispackagedir) >>> l2 = filter(lambda x: not x.endswith('.swp'), l2) >>> len(l2) - 33 + 28 """ files=[] ls = os.listdir(path) -- 2.11.4.GIT