Menu

[r7472]: / branches / mathtex / test / run-mpl-test.py  Maximize  Restore  History

Download this file

107 lines (80 with data), 2.8 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
#!/bin/env python
"""
TODO-NOTES:
Command-line executable that runs the tests.
-- nice report on test pass/fail status
-- hooks to add coverage checking and reporting
Utilities
-- image comparison tools (non-PIL dependant)
"""
import os
import sys
import os.path
# Save stdout/stderr
originalStdout = sys.stdout
originalStderr = sys.stderr
# get the current directory and the root test directory
cwd = os.path.abspath( os.getcwd() )
root = os.path.dirname( os.path.abspath( sys.argv[0] ) )
sys.path = [ root ] + sys.path
# command-line arguments
args = [ arg for arg in sys.argv ]
# determine the actual working directory to use
if root in cwd:
working = cwd
else:
working = root
if '--all' in args:
working = root
# print "DBG: mpl.test.run - cwd = '%s'" % (cwd)
# print "DBG: mpl.test.run - root = '%s'" % (root)
# print "DBG: mpl.test.run - working = '%s'" % (working)
# make the working directory current
os.chdir( working )
import nose
from mplTest import MplNosePlugin, path_utils
if '--clean' in args:
# perform the cleaning process and exit
for filename in path_utils.walk( working ):
ext = path_utils.extension( filename )
if ext == '.cover':
print "Cleaning coverage file: %s" % (filename)
path_utils.rm( filename )
elif ext == '.pyc':
print "Cleaning bytecode file: %s" % (filename)
path_utils.rm( filename )
elif path_utils.name( filename ) == 'saved-results':
print "Cleaning directory: %s" % (filename)
path_utils.rmdir( filename )
sys.exit( 0 )
for arg in args:
# We need to do this here, because we do not actually want nose to start.
if arg.startswith( '--make-test=' ):
testname = arg[ 12: ]
# Remove any surrounding quotation marks
if (testname[0] == '"' and testname[-1] == '"') or \
(testname[0] == "'" and testname[-1] == "'"):
testname = testname[1:-1]
filename = os.path.join( cwd, 'Test' + testname + '.py' )
templName = os.path.join( root, 'mplTest', "TestTEMPLATE.py" )
fin = open( templName, "r" )
fout = open( filename, "w" )
lines = fin.readlines()
for line in lines:
newline = line.replace( 'UNITTEST', testname )
fout.write( newline )
fin.close()
fout.close()
print "Generated '%s'" % (filename)
sys.exit( 0 )
### Run nose
nose.run( argv = args,
plugins = [ MplNosePlugin() ] )
### do other stuff here
# $> nosetests [-w <working_directory>]
# Run a specific test
# $> nosetests tests/test_stuff.py:test_function
# $> nosetests tests/test_stuff.py:TestClass.test_method
# Restore the original stdout/stderr
sys.stdout = originalStdout
sys.stderr = originalStderr
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.