Beispiel #1
0
 def test_printErrorsSkipreport(self):
     """
     printErrors() prints the skip report.
     """
     self.args.verbose = 1
     gtr = GreenTestResult(self.args, GreenStream(self.stream))
     pt = MyProtoTest()
     reason = "dog ate homework"
     gtr.addSkip(pt, reason)
     gtr.printErrors()
     self.assertIn(reason, self.stream.getvalue())
Beispiel #2
0
 def test_printErrorsSkipreport(self):
     """
     printErrors() prints the skip report.
     """
     self.args.verbose = 1
     gtr = GreenTestResult(self.args, GreenStream(self.stream))
     pt = MyProtoTest()
     reason = "dog ate homework"
     gtr.addSkip(pt, reason)
     gtr.printErrors()
     self.assertIn(reason, self.stream.getvalue())
Beispiel #3
0
 def test_printErrorsStdout(self):
     """
     printErrors() prints out the captured stdout.
     """
     self.args.verbose = 1
     self.args.termcolor = False
     gtr = GreenTestResult(self.args, GreenStream(self.stream))
     pt = MyProtoTest()
     output = 'this is what the test spit out to stdout'
     gtr.recordStdout(pt, output)
     gtr.addSuccess(pt)
     gtr.printErrors()
     self.assertIn(output, self.stream.getvalue())
Beispiel #4
0
 def test_printErrorsStdout(self):
     """
     printErrors() prints out the captured stdout.
     """
     self.args.verbose = 1
     self.args.termcolor = False
     gtr = GreenTestResult(self.args, GreenStream(self.stream))
     pt = MyProtoTest()
     output = 'this is what the test spit out to stdout'
     gtr.recordStdout(pt, output)
     gtr.addSuccess(pt)
     gtr.printErrors()
     self.assertIn(output, self.stream.getvalue())
Beispiel #5
0
 def test_printErrorsDots(self):
     "printErrors() looks correct in verbose=1 (dots) mode"
     try:
         raise Exception
     except:
         err = sys.exc_info()
     gtr = GreenTestResult(GreenStream(self.stream), None, 1)
     test = MagicMock()
     gtr.addError(test, proto_error(err))
     gtr.printErrors()
     self.assertTrue('\n\n' in self.stream.getvalue())
     self.assertTrue('test_printErrorsDots' in self.stream.getvalue())
     self.assertTrue('raise Exception' in self.stream.getvalue())
     self.assertTrue('Error' in self.stream.getvalue())
Beispiel #6
0
 def test_printErrorsStderrQuietStdoutOnSuccess(self):
     """
     printErrors() prints out the captured stdout
     except when quiet_stdout is set to True
     for successful tests.
     """
     self.args.quiet_stdout = True
     gtr = GreenTestResult(self.args, GreenStream(self.stream))
     pt = MyProtoTest()
     output = 'this is what the test should not spit out to stdout'
     gtr.recordStderr(pt, output)
     gtr.addSuccess(pt)
     gtr.printErrors()
     self.assertNotIn(output, self.stream.getvalue())
Beispiel #7
0
 def test_printErrorsStderrQuietStdoutOnSuccess(self):
     """
     printErrors() prints out the captured stdout
     except when quiet_stdout is set to True
     for successful tests.
     """
     self.args.quiet_stdout = True
     gtr = GreenTestResult(self.args, GreenStream(self.stream))
     pt = MyProtoTest()
     output = 'this is what the test should not spit out to stdout'
     gtr.recordStderr(pt, output)
     gtr.addSuccess(pt)
     gtr.printErrors()
     self.assertNotIn(output, self.stream.getvalue())
Beispiel #8
0
 def test_printErrorsVerbose2(self):
     "printErrors() looks correct in verbose=2 mode"
     try:
         raise Exception
     except:
         err = sys.exc_info()
     gtr = GreenTestResult(GreenStream(self.stream), None, 2)
     gtr.test_output_line = "   some test output"
     test = MagicMock()
     gtr.addError(test, proto_error(err))
     gtr.printErrors()
     self.assertTrue('\n\n' in self.stream.getvalue())
     self.assertTrue('test_printErrorsVerbose2' in self.stream.getvalue())
     self.assertTrue('raise Exception' in self.stream.getvalue())
     self.assertTrue('Error' in self.stream.getvalue())
Beispiel #9
0
 def test_printErrorsNoTracebacks(self):
     """
     printErrors() omits tracebacks for failures and errors when
     no_tracebacks is True
     """
     self.args.no_tracebacks = True
     try:
         raise Exception
     except:
         err = sys.exc_info()
     gtr = GreenTestResult(self.args, GreenStream(self.stream))
     pt = MyProtoTest()
     gtr.addError(pt, proto_error(err))
     gtr.printErrors()
     self.assertNotIn("Exception", self.stream.getvalue())
Beispiel #10
0
 def test_printErrorsNoTracebacks(self):
     """
     printErrors() omits tracebacks for failures and errors when
     no_tracebacks is True
     """
     self.args.no_tracebacks = True
     try:
         raise Exception
     except:
         err = sys.exc_info()
     gtr = GreenTestResult(self.args, GreenStream(self.stream))
     pt = MyProtoTest()
     gtr.addError(pt, proto_error(err))
     gtr.printErrors()
     self.assertNotIn("Exception", self.stream.getvalue())
Beispiel #11
0
 def test_printErrorsVerbose3(self):
     """
     printErrors() looks correct in verbose=3 mode
     """
     try:
         raise Exception
     except:
         err = sys.exc_info()
     gtr = GreenTestResult(GreenStream(self.stream), None, 3, False, False)
     gtr.addError(MyProtoTest(), proto_error(err))
     gtr.printErrors()
     self.assertIn('\n\n', self.stream.getvalue())
     self.assertIn('my_module.MyClass.myMethod', self.stream.getvalue())
     self.assertIn('test_printErrorsVerbose3', self.stream.getvalue())
     self.assertIn('raise Exception', self.stream.getvalue())
     self.assertIn('Error', self.stream.getvalue())
Beispiel #12
0
 def test_printErrorsDots(self):
     """
     printErrors() looks correct in verbose=1 (dots) mode.
     """
     try:
         raise Exception
     except:
         err = sys.exc_info()
     self.args.verbose = 1
     self.args.termcolor = False
     gtr = GreenTestResult(self.args, GreenStream(self.stream))
     gtr.addError(MyProtoTest(), proto_error(err))
     gtr.printErrors()
     self.assertIn("\n\n", self.stream.getvalue())
     self.assertIn("my_module.MyClass.myMethod", self.stream.getvalue())
     self.assertIn("test_printErrorsDots", self.stream.getvalue())
     self.assertIn("raise Exception", self.stream.getvalue())
     self.assertIn("Error", self.stream.getvalue())
Beispiel #13
0
 def test_printErrors_Py2Unicode(self):
     """
     printErrors() doesn't crash in Python 2 when tracebacks contain unicode
     """
     try:
         raise Exception(u'Das Böse ist immer und überall')
     except:
         err = sys.exc_info()
     self.args.verbose = 1
     self.args.termcolor = False
     gtr = GreenTestResult(self.args, GreenStream(self.stream))
     gtr.addError(MyProtoTest(), proto_error(err))
     gtr.printErrors() # We shouldn't hit an exception here
     self.assertIn('\n\n', self.stream.getvalue())
     self.assertIn('my_module.MyClass.myMethod', self.stream.getvalue())
     self.assertIn('raise Exception', self.stream.getvalue())
     self.assertIn('Error', self.stream.getvalue())
     self.assertIn('Böse', self.stream.getvalue())
Beispiel #14
0
 def test_printErrorsVerbose2(self):
     """
     printErrors() looks correct in verbose=2 mode.
     """
     try:
         raise Exception
     except:
         err = sys.exc_info()
     self.args.verbose = 2
     self.args.termcolor = False
     gtr = GreenTestResult(self.args, GreenStream(self.stream))
     gtr.addError(MyProtoTest(), proto_error(err))
     gtr.printErrors()
     self.assertIn('\n\n', self.stream.getvalue())
     self.assertIn('my_module.MyClass.myMethod', self.stream.getvalue())
     self.assertIn('test_printErrorsVerbose2', self.stream.getvalue())
     self.assertIn('raise Exception', self.stream.getvalue())
     self.assertIn('Error', self.stream.getvalue())
Beispiel #15
0
 def test_printErrors_Py2Unicode(self):
     """
     printErrors() doesn't crash in Python 2 when tracebacks contain unicode
     """
     try:
         raise Exception(u'Das Böse ist immer und überall')
     except:
         err = sys.exc_info()
     self.args.verbose = 1
     self.args.termcolor = False
     gtr = GreenTestResult(self.args, GreenStream(self.stream))
     gtr.addError(MyProtoTest(), proto_error(err))
     gtr.printErrors() # We shouldn't hit an exception here
     self.assertIn('\n\n', self.stream.getvalue())
     self.assertIn('my_module.MyClass.myMethod', self.stream.getvalue())
     self.assertIn('raise Exception', self.stream.getvalue())
     self.assertIn('Error', self.stream.getvalue())
     self.assertIn('Böse', self.stream.getvalue())
Beispiel #16
0
 def test_printErrorsVerbose3(self):
     """
     printErrors() looks correct in verbose=3 mode.
     """
     try:
         raise Exception
     except:
         err = sys.exc_info()
     self.args.verbose = 3
     self.args.termcolor = False
     gtr = GreenTestResult(self.args, GreenStream(self.stream))
     gtr.addError(MyProtoTest(), proto_error(err))
     gtr.printErrors()
     self.assertIn('\n\n', self.stream.getvalue())
     self.assertIn('my_module.MyClass.myMethod', self.stream.getvalue())
     self.assertIn('test_printErrorsVerbose3', self.stream.getvalue())
     self.assertIn('raise Exception', self.stream.getvalue())
     self.assertIn('Error', self.stream.getvalue())
Beispiel #17
0
 def test_printErrorsStdoutQuietStdoutOnError(self):
     """
     printErrors() prints out the captured stdout
     except when quiet_stdout is set to True
     for successful tests, but here we are on a
     failling test.
     """
     self.args.quiet_stdout = True
     try:
         raise Exception
     except:
         err = sys.exc_info()
     gtr = GreenTestResult(self.args, GreenStream(self.stream))
     pt = MyProtoTest()
     output = 'this is what the test should spit out to stdout'
     gtr.recordStdout(pt, output)
     gtr.addError(pt, proto_error(err))
     gtr.printErrors()
     self.assertIn(output, self.stream.getvalue())
Beispiel #18
0
 def test_printErrorsStdoutQuietStdoutOnError(self):
     """
     printErrors() prints out the captured stdout
     except when quiet_stdout is set to True
     for successful tests, but here we are on a
     failing test.
     """
     self.args.quiet_stdout = True
     try:
         raise Exception
     except:
         err = sys.exc_info()
     gtr = GreenTestResult(self.args, GreenStream(self.stream))
     pt = MyProtoTest()
     output = 'this is what the test should spit out to stdout'
     gtr.recordStdout(pt, output)
     gtr.addError(pt, proto_error(err))
     gtr.printErrors()
     self.assertIn(output, self.stream.getvalue())
Beispiel #19
0
 def test_printErrorsZHTML(self):
     "printErrors() looks correct in html mode"
     try:
         raise Exception
     except:
         err = sys.exc_info()
     gtr = GreenTestResult(GreenStream(self.stream), None, 4)
     gtr.colors.html = True
     gtr.test_output_line = "   some test output"
     test = MagicMock()
     gtr.addError(test, proto_error(err))
     gtr.printErrors()
     self.assertTrue('\n\n' in self.stream.getvalue())
     self.assertTrue('(most recent call last)' in self.stream.getvalue())
     self.assertTrue('test_printErrorsZHTML' in self.stream.getvalue())
     self.assertTrue('raise Exception' in self.stream.getvalue())
     self.assertTrue('Error' in self.stream.getvalue())
     self.assertTrue('<span' in self.stream.getvalue())
     self.assertTrue('color: rgb(' in self.stream.getvalue())
Beispiel #20
0
 def test_printErrorsVerbose4(self):
     """
     printErrors() looks correct in verbose=4 mode
     """
     try:
         raise Exception
     except:
         err = sys.exc_info()
     self.args.verbose = 4
     self.args.termcolor = False
     self.args.html = False
     gtr = GreenTestResult(self.args, GreenStream(self.stream))
     gtr.addError(MyProtoTest(), err)
     gtr.printErrors()
     self.assertIn('\n\n', self.stream.getvalue())
     self.assertIn('(most recent call last)', self.stream.getvalue())
     self.assertIn('my_module.MyClass.myMethod', self.stream.getvalue())
     self.assertIn('test_printErrorsVerbose4', self.stream.getvalue())
     self.assertIn('raise Exception', self.stream.getvalue())
     self.assertIn('Error', self.stream.getvalue())
Beispiel #21
0
 def test_printErrorsZHTML(self):
     """
     printErrors() looks correct in html mode
     """
     try:
         raise Exception
     except:
         err = sys.exc_info()
     self.args.verbose = 4
     gtr = GreenTestResult(self.args, GreenStream(self.stream))
     gtr.colors.html = True
     test = MagicMock()
     gtr.addError(test, proto_error(err))
     gtr.printErrors()
     self.assertIn('\n\n', self.stream.getvalue())
     self.assertIn('(most recent call last)', self.stream.getvalue())
     self.assertIn('test_printErrorsZHTML', self.stream.getvalue())
     self.assertIn('raise Exception', self.stream.getvalue())
     self.assertIn('Error', self.stream.getvalue())
     self.assertIn('<span', self.stream.getvalue())
     self.assertIn('color: rgb(', self.stream.getvalue())