__init__.py :  » XML » 4Suite » 4Suite-XML-1.0.2 » Ft » Lib » TestSuite » Python Open Source

Home
Python Open Source
1.3.1.2 Python
2.Ajax
3.Aspect Oriented
4.Blog
5.Build
6.Business Application
7.Chart Report
8.Content Management Systems
9.Cryptographic
10.Database
11.Development
12.Editor
13.Email
14.ERP
15.Game 2D 3D
16.GIS
17.GUI
18.IDE
19.Installer
20.IRC
21.Issue Tracker
22.Language Interface
23.Log
24.Math
25.Media Sound Audio
26.Mobile
27.Network
28.Parser
29.PDF
30.Project Management
31.RSS
32.Search
33.Security
34.Template Engines
35.Test
36.UML
37.USB Serial
38.Web Frameworks
39.Web Server
40.Web Services
41.Web Unit
42.Wiki
43.Windows
44.XML
Python Open Source » XML » 4Suite 
4Suite » 4Suite XML 1.0.2 » Ft » Lib » TestSuite » __init__.py
########################################################################
# $Header: /var/local/cvsroot/4Suite/Ft/Lib/TestSuite/__init__.py,v 1.3 2002/07/23 06:15:53 jkloth Exp $
"""
Package for testing utilities

Copyright 2002 Fourthought, Inc. (USA).
Detailed license and copyright information: http://4suite.org/COPYRIGHT
Project home, documentation, distributions: http://4suite.org/
"""

__revision__ = "$Id: __init__.py,v 1.3 2002/07/23 06:15:53 jkloth Exp $"

def RemoveTests(list, ignored):
    for test in ignored:
        if test in list:
            list.remove(test)
    return list


def SortTests(list, atstart, atend=[]):
    ordered = {}
    position = 0
    for test in atstart:
        ordered[test] = position
        position += 1

    middle = position

    for test in atend:
        position += 1
        ordered[test] = position

    def dictsort(a, b, dict=ordered, default=middle):
        a = dict.get(a, default)
        b = dict.get(b, default)
        return cmp(a, b)

    list.sort(dictsort)

    return list


def Test(**attrs):
    import sys, os
    import TestSuite, Errors
    
    if not attrs.has_key('script_name'):
        attrs['script_name'] = sys.argv[0]

    if not attrs.has_key('script_args'):
        attrs['script_args'] = sys.argv[1:]

    # Create the TestSuite instance using the arguments to initialize it.
    test_dir = os.path.dirname(attrs['script_name']) or os.getcwd()
    try:
        sys.path.insert(0, test_dir)
        try:
            suite = TestSuite.TestSuite(attrs)
        except Errors.TestSuiteSetupError, msg:
            if attrs.has_key('name'):
                raise SystemExit, \
                      'error in %s test command: %s' % (attrs['name'], msg)
            else:
                raise SystemExit, \
                      'error in test command: %s' % msg

        try:
            ok = suite.parseCommandLine()
        except Errors.TestSuiteArgumentError, msg:
            raise SystemExit, \
                  suite.generateUsage() + '\nerror: %s' % msg

        if ok:
            try:
                suite.runTests()
            except (IOError, OSError), error:
                from distutils.util import grok_environment_error
                error = grok_environment_error(error)
                raise SystemExit(error)
            except Errors.TestSuiteError, error:
                raise SystemExit(str(error))
    finally:
        del sys.path[0]
    return suite
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.