def test_multi_reporters(self): self.dest = 'reports' reporter1 = unishark.HtmlReporter( overview_title='My Title', overview_description= u'My Description: : \n\t<~!@#$%^&*()_+=-?/>,;."\u6c49"' u'\r\n', dest=self.dest) reporter2 = unishark.XUnitReporter(summary_title='My Title', dest=self.dest) unishark.BufferedTestRunner(reporters=[reporter1, reporter2]).run( self.suite1) reporter1.collect() reporter2.collect() exp_filenames = [ 'test_xunit_result.xml', 'summary_xunit_result.xml', 'index.html', 'overview.html', 'test_result.html' ] filenames = os.listdir(os.path.join(self.dest)) self.assertSetEqual(set(filenames), set(exp_filenames))
def test_html_report(self): reporter = unishark.HtmlReporter() result = unishark.BufferedTestRunner().run( self.suite1, name='My Suite 1', description=u'Description 1: \n\t<~!@#$%^&*()_+=-?/>,;."\u6c49"\r\n' ) reporter.report(result) result = unishark.BufferedTestRunner().run( self.suite2, name='My Suite 2', description=u'Description 2: \n\t<~!@#$%^&*()_+=-?/>,;."\u6c49"\r\n' ) reporter.report(result) reporter.collect() exp_filenames = [ 'index.html', 'overview.html', 'My Suite 1_result.html', 'My Suite 2_result.html' ] filenames = os.listdir(self.dest) self.assertSetEqual(set(filenames), set(exp_filenames))
log.info('Here is logging of test_6') self.assertEqual(1, 1) @unittest.skip('Reason of skipping test_7') def test_7(self): """Here is test_7's doc str""" self.assertEqual(1, 1) class MyTestClass4(unittest.TestCase): def test_8(self): """Here is test_8's doc str""" log.debug('There is an error') raise TypeError def test_9(self): """Here is test_9's doc str""" log.error('This is a failure case, which raises AssertionError') self.assertEqual(1, 2) def test_10(self): """Here is test_10's doc str""" log.info('Here is test_10 INFO log') log.debug('Here is test_10 DEBUG log') self.assertEqual(1, 1) if __name__ == '__main__': import unishark reporter = unishark.HtmlReporter(dest='log') unittest.main(testRunner=unishark.BufferedTestRunner([reporter]))
def test_init_with_non_iterable_reporters(self): unishark.BufferedTestRunner(reporters=unishark.HtmlReporter())
def test_init_with_non_iterable_reporters(self): with self.assertRaises(TypeError): unishark.BufferedTestRunner(reporters=unishark.HtmlReporter())