def tearDown(self): """ Update summary with data from this test. This is a really hackey way of doing it-- we get a startup event from module load, but there is no way in unittest to get a single shutdown event-- except for stuff in 2.7 and above So what we do here is to read the existing file, stick in more content, and leave it """ svgFile = os.path.join(OUTDIR,self._testMethodName + ".svg") #all tests do not produce output if os.path.exists(svgFile): existingSummary = readFileAsString(SUMMARY_FILE) svgText = readFileAsString(svgFile) svgText = svgText.replace('<?xml version="1.0" encoding="UTF-8" standalone="no"?>',"") #now write data into the file #the content we are replacing it with also includes the marker, so it can be replaced again existingSummary = existingSummary.replace("<!--TEST_CONTENT-->", TEST_RESULT_TEMPLATE % ( dict(svg=svgText, name=self._testMethodName))) writeStringToFile(existingSummary,SUMMARY_FILE)
def tearDown(self): """ Update summary with data from this test. This is a really hackey way of doing it-- we get a startup event from module load, but there is no way in unittest to get a single shutdown event-- except for stuff in 2.7 and above So what we do here is to read the existing file, stick in more content, and leave it """ svgFile = os.path.join(OUTDIR, self._testMethodName + ".svg") # all tests do not produce output if os.path.exists(svgFile): existingSummary = readFileAsString(SUMMARY_FILE) svgText = readFileAsString(svgFile) svgText = svgText.replace( '<?xml version="1.0" encoding="UTF-8" standalone="no"?>', "") # now write data into the file # the content we are replacing it with also includes the marker, so it can be replaced again existingSummary = existingSummary.replace( "<!--TEST_CONTENT-->", TEST_RESULT_TEMPLATE % (dict(svg=svgText, name=self._testMethodName))) writeStringToFile(existingSummary, SUMMARY_FILE)
</head> <body> <!--TEST_CONTENT--> </body> </html>""" TEST_RESULT_TEMPLATE=""" <div class="testResult"><h3>%(name)s</h3> %(svg)s </div> <!--TEST_CONTENT--> """ #clean up any summary file that is in the output directory. #i know, this sux, but there is no other way to do this in 2.6, as we cannot do class fixutres till 2.7 writeStringToFile(SUMMARY_TEMPLATE,SUMMARY_FILE) class TestCadQuery(BaseTest): def tearDown(self): """ Update summary with data from this test. This is a really hackey way of doing it-- we get a startup event from module load, but there is no way in unittest to get a single shutdown event-- except for stuff in 2.7 and above So what we do here is to read the existing file, stick in more content, and leave it """ svgFile = os.path.join(OUTDIR,self._testMethodName + ".svg") #all tests do not produce output
</head> <body> <!--TEST_CONTENT--> </body> </html>""" TEST_RESULT_TEMPLATE = """ <div class="testResult"><h3>%(name)s</h3> %(svg)s </div> <!--TEST_CONTENT--> """ # clean up any summary file that is in the output directory. # i know, this sux, but there is no other way to do this in 2.6, as we cannot do class fixutres till 2.7 writeStringToFile(SUMMARY_TEMPLATE, SUMMARY_FILE) class TestCadQuery(BaseTest): def tearDown(self): """ Update summary with data from this test. This is a really hackey way of doing it-- we get a startup event from module load, but there is no way in unittest to get a single shutdown event-- except for stuff in 2.7 and above So what we do here is to read the existing file, stick in more content, and leave it """ svgFile = os.path.join(OUTDIR, self._testMethodName + ".svg") # all tests do not produce output if os.path.exists(svgFile):