[Zope-CVS] CVS: Packages/zpkgtools/zpkgtools/tests - runtests.py:1.1

Fred L. Drake, Jr. fred at zope.com
Thu Mar 18 13:06:39 EST 2004


Update of /cvs-repository/Packages/zpkgtools/zpkgtools/tests
In directory cvs.zope.org:/tmp/cvs-serv3129

Added Files:
	runtests.py 
Log Message:
convenience script to run all the tests for zpkgtools; this is cut
down from the more elaborate ZConfig script of the same name


=== Added File Packages/zpkgtools/zpkgtools/tests/runtests.py ===
#! /usr/bin/env python
##############################################################################
#
# Copyright (c) 2002, 2003 Zope Corporation and Contributors.
# All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.0 (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.
#
##############################################################################
"""Script to run all the regression tests for zpkgtools."""

import os
import sys
import unittest

if __name__ == "__main__":
    __file__ = sys.argv[0]

TESTDIR = os.path.dirname(os.path.abspath(__file__))

PKGDIR = os.path.dirname(TESTDIR) # the package directory
TOPDIR = os.path.dirname(PKGDIR)


def load_tests(name):
    name = "zpkgtools.tests." + name
    __import__(name)
    mod = sys.modules[name]
    return mod.test_suite()

def test_suite():
    L = []
    for fn in os.listdir(TESTDIR):
        name, ext = os.path.splitext(fn)
        if name[:4] == "test" and ext == ".py":
            L.append(load_tests(name))
    suite = L.pop()
    for t in L:
        suite.addTest(t)
    return suite

if __name__ == "__main__":
    if TOPDIR not in sys.path:
        sys.path.insert(0, TOPDIR)
    unittest.main(defaultTest="test_suite")




More information about the Zope-CVS mailing list