run_all_tests.py :  » USB-Serial » Python-Serial-Port-Extension » pyserial-2.5-rc2 » test » 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 » USB Serial » Python Serial Port Extension 
Python Serial Port Extension » pyserial 2.5 rc2 » test » run_all_tests.py
#! /usr/bin/env python

"""\
UnitTest runner. This one searches for all files named test_*.py and collects
all test cases from these files. Finally it runs all tests and prints a
summary.
"""

import unittest
import sys
import os
import time

# inject local copy to avoid testing the installed version instead of the
# working copy
sys.path.insert(0, '..')

import serial
print "Patching sys.path to test local version. Testing Version: %s" % (serial.VERSION,)

PORT = 'loop://'
if len(sys.argv) > 1:
    PORT = sys.argv[1]

# find files and the tests in them
mainsuite = unittest.TestSuite()
for modulename in [os.path.splitext(x)[0]
    for x in os.listdir('.')
        if x != __file__ and x.startswith("test_") and x.endswith(".py")
]:
    try:
        module = __import__(modulename)
    except ImportError:
        print "skipping %s" % modulename
    else:
        module.PORT = PORT
        testsuite = unittest.findTestCases(module)
        print "found %s tests in %r" % (testsuite.countTestCases(), modulename)
        mainsuite.addTest(testsuite)

verbosity = 1
if '-v' in sys.argv[1:]:
    verbosity = 2

# run the collected tests
testRunner = unittest.TextTestRunner(verbosity=verbosity)
#~ testRunner = unittest.ConsoleTestRunner(verbosity=verbosity)
result = testRunner.run(mainsuite)

# set exit code accordingly to test results
sys.exit(not result.wasSuccessful())
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.