def main(pattern='test_*.py'): try: folder = os.path.dirname(__file__) except: folder = os.path.dirname(sys.argv[0]) or os.getcwd() from reportlab.lib.utils import isSourceDistro haveSRC = isSourceDistro() def cleanup(folder,patterns=('*.pdf', '*.log','*.svg','runAll.txt', 'test_*.txt')): for pat in patterns: for filename in GlobDirectoryWalker(folder, pattern=pat): try: os.remove(filename) except: pass # special case for reportlab/test directory - clean up # all PDF & log files before starting run. You don't # want this if reusing runAll anywhere else. if string.find(folder, 'reportlab' + os.sep + 'test') > -1: cleanup(folder) cleanup(outputfile('')) NI = [] testSuite = makeSuite(folder,nonImportable=NI,pattern=pattern+(not haveSRC and 'c' or '')) unittest.TextTestRunner().run(testSuite) if haveSRC: cleanup(folder,patterns=('*.pyc','*.pyo')) if NI: sys.stderr.write('\n###################### the following tests could not be imported\n') for f,tb in NI: print 'file: "%s"\n%s\n' % (f,string.join(tb,'')) print 'Logs and output files written to folder "%s"' % outputfile('')
def main(pattern='test_*.py'): try: folder = os.path.dirname(__file__) assert folder except: folder = os.path.dirname(sys.argv[0]) or os.getcwd() #allow for Benn's "screwball cygwin distro": if not folder: folder = '.' from reportlab.lib.utils import isSourceDistro haveSRC = isSourceDistro() def cleanup(folder, patterns=('*.pdf', '*.log', '*.svg', 'runAll.txt', 'test_*.txt', '_i_am_actually_a_*.*')): if not folder: return for pat in patterns: for filename in GlobDirectoryWalker(folder, pattern=pat): try: os.remove(filename) except: pass # special case for tests directory - clean up # all PDF & log files before starting run. You don't # want this if reusing runAll anywhere else. if os.sep + 'tests' in folder: cleanup(folder) cleanup(outputfile('')) NI = [] cleanOnly = '--clean' in sys.argv if not cleanOnly: testSuite = makeSuite( folder, nonImportable=NI, pattern=pattern + (not haveSRC and 'c' or '')) unittest.TextTestRunner().run(testSuite) if haveSRC: cleanup(folder, patterns=('*.pyc', '*.pyo')) if not cleanOnly: if NI: sys.stderr.write( '\n###################### the following tests could not be imported\n' ) for f, tb in NI: print('file: "%s"\n%s\n' % (f, ''.join(tb))) printLocation()
def main(pattern='test_*.py'): try: folder = os.path.dirname(__file__) assert folder except: folder = os.path.dirname(sys.argv[0]) or os.getcwd() #allow for Benn's "screwball cygwin distro": if not folder: folder = '.' from reportlab.lib.utils import isSourceDistro haveSRC = isSourceDistro() def cleanup(folder, patterns=('*.pdf', '*.log', '*.svg', 'runAll.txt', 'test_*.txt', '_i_am_actually_a_*.*')): if not folder: return for pat in patterns: for filename in GlobDirectoryWalker(folder, pattern=pat): try: os.remove(filename) except: pass # special case for tests directory - clean up # all PDF & log files before starting run. You don't # want this if reusing runAll anywhere else. if os.sep + 'tests' in folder: cleanup(folder) cleanup(outputfile('')) NI = [] cleanOnly = '--clean' in sys.argv if not cleanOnly: testSuite = makeSuite(folder, nonImportable=NI, pattern=pattern + (not haveSRC and 'c' or '')) unittest.TextTestRunner().run(testSuite) if haveSRC: cleanup(folder, patterns=('*.pyc', '*.pyo')) if not cleanOnly: if NI: sys.stderr.write( '\n###################### the following tests could not be imported\n' ) for f, tb in NI: print('file: "%s"\n%s\n' % (f, ''.join(tb))) printLocation()
def main(pattern="test_*.py"): try: folder = os.path.dirname(__file__) assert folder except: folder = os.path.dirname(sys.argv[0]) or os.getcwd() # allow for Benn's "screwball cygwin distro": if not folder: folder = "." from reportlab.lib.utils import isSourceDistro haveSRC = isSourceDistro() def cleanup(folder, patterns=("*.pdf", "*.log", "*.svg", "runAll.txt", "test_*.txt", "_i_am_actually_a_*.*")): if not folder: return for pat in patterns: for filename in GlobDirectoryWalker(folder, pattern=pat): try: os.remove(filename) except: pass # special case for tests directory - clean up # all PDF & log files before starting run. You don't # want this if reusing runAll anywhere else. if string.find(folder, os.sep + "tests") > -1: cleanup(folder) cleanup(outputfile("")) NI = [] cleanOnly = "--clean" in sys.argv if not cleanOnly: testSuite = makeSuite(folder, nonImportable=NI, pattern=pattern + (not haveSRC and "c" or "")) unittest.TextTestRunner().run(testSuite) if haveSRC: cleanup(folder, patterns=("*.pyc", "*.pyo")) if not cleanOnly: if NI: sys.stderr.write("\n###################### the following tests could not be imported\n") for f, tb in NI: print('file: "%s"\n%s\n' % (f, string.join(tb, ""))) printLocation()