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()
c.save() def test_rl_config_reset(self): from reportlab import rl_config from reportlab.pdfbase import pdfmetrics, _fontdata tfd = pdfmetrics._typefaces fbn = _fontdata.fontsByName tfd[" a "] = 1 fbn[" b "] = 1 ntfd = len(tfd) nfbn = len(fbn) from reportlab.lib import sequencer seq = sequencer.getSequencer() seq._dingo = 1 rl_config._reset() assert not hasattr(seq, "_dingo") assert " a " not in tfd and len(tfd) < ntfd assert " a " not in fbn and len(fbn) < nfbn def makeSuite(): return makeSuiteForClasses(HelloTestCase) # noruntests if __name__ == "__main__": unittest.TextTestRunner().run(makeSuite()) printLocation()
c.setTrimBox((0.01,0.01,w-0.02,h-0.02)) c.drawString(100, 700, 'Hello World!') c.showPage() c.save() def trySomeColors(C,enforceColorSpace=None): from reportlab.lib.utils import getBytesIO out=getBytesIO() canv = canvas.Canvas(out,enforceColorSpace=enforceColorSpace) canv.setFont('Helvetica',10) x = 0 y = 0 w,h = canv._pagesize for c in C: if y+10>h: y = 0 x += 10 canv.setFillColor(c) canv.rect(x,y,10,10,fill=1,stroke=0) y += 10 canv.showPage() canv.save() def makeSuite(): return makeSuiteForClasses(PdfgenTestCase) #noruntests if __name__ == "__main__": unittest.TextTestRunner().run(makeSuite()) printLocation()