def test_reportOutcome(self): """ _reportOutcome contains output we expect """ gtr = GreenTestResult(GreenStream(self.stream), None, 1) gtr._reportOutcome(None, '.', lambda x: x) self.assertIn('.', self.stream.getvalue())
def test_reportOutcome(self): """ _reportOutcome contains output we expect. """ self.args.verbose = 1 gtr = GreenTestResult(self.args, GreenStream(self.stream)) gtr._reportOutcome(None, '.', lambda x: x) self.assertIn('.', self.stream.getvalue())
def test_reportOutcomeVerbose(self): "_reportOutcome contains output we expect in verbose mode" gtr = GreenTestResult(GreenStream(self.stream), None, 2) r = 'a fake reason' t = MagicMock() t.__str__.return_value = 'junk' gtr._reportOutcome(t, '.', lambda x: x, None, r) self.assertTrue(r in self.stream.getvalue())
def test_reportOutcome(self): """ _reportOutcome contains output we expect. """ self.args.verbose = 1 gtr = GreenTestResult(self.args, GreenStream(self.stream)) gtr._reportOutcome(None, '.', lambda x: x) self.assertIn('.', self.stream.getvalue())
def test_reportOutcomeVerboseHTML(self): "html=True causes _reportOutcome() to escape HTML in docstrings" gtr = GreenTestResult(GreenStream(self.stream), None, 3) gtr.colors.html = True r = 'a fake reason' t = MagicMock() t.shortDescription.return_value = 'a fake test output line <>' gtr._reportOutcome(t, '.', lambda x: x, None, r) self.assertTrue(r in self.stream.getvalue()) self.assertTrue('&' in self.stream.getvalue()) self.assertTrue('<' in self.stream.getvalue()) self.assertTrue('>' in self.stream.getvalue()) self.assertFalse(' ' in self.stream.getvalue()) self.assertFalse('<' in self.stream.getvalue()) self.assertFalse('>' in self.stream.getvalue())
def test_reportOutcomeVerbose(self): """ _reportOutcome contains output we expect in verbose mode """ self.args.verbose = 2 def isatty(): return True gs = GreenStream(self.stream) gs.isatty = isatty gtr = GreenTestResult(self.args, gs) r = 'a fake reason' t = MagicMock() t.__str__.return_value = 'junk' gtr._reportOutcome(t, '.', lambda x: x, None, r) self.assertIn(r, self.stream.getvalue())
def test_reportOutcomeCursorUp(self): """ _reportOutcome moves the cursor up when it needs to """ self.args.verbose = 2 def isatty(): return True gs = GreenStream(self.stream) gs.isatty = isatty gtr = GreenTestResult(self.args, gs) r = 'a fake reason' t = MagicMock() t.__str__.return_value = 'x' * 1000 gtr._reportOutcome(t, '.', lambda x: x, None, r) self.assertIn(r, self.stream.getvalue()) self.assertLess(len(self.stream.getvalue()), 2000)
def test_reportOutcomeCursorUp(self): """ _reportOutcome moves the cursor up when it needs to """ self.args.verbose = 2 def isatty(): return True gs = GreenStream(self.stream) gs.isatty = isatty gtr = GreenTestResult(self.args, gs) r = 'a fake reason' t = MagicMock() t.__str__.return_value = 'x' * 1000 gtr._reportOutcome(t, '.', lambda x: x, None, r) self.assertIn(r, self.stream.getvalue()) self.assertLess(len(self.stream.getvalue()), 2000)
def test_reportOutcomeVerboseHTML(self): """ html=True causes _reportOutcome() to escape HTML in docstrings """ gtr = GreenTestResult(GreenStream(self.stream), None, 3) gtr.colors.html = True r = 'a fake reason' class Injection(unittest.TestCase): def test_method(self): 'a fake test output line <>' t = proto_test(Injection('test_method')) gtr._reportOutcome(t, '.', lambda x: x, None, r) self.assertTrue(r in self.stream.getvalue()) self.assertTrue('&' in self.stream.getvalue()) self.assertTrue('<' in self.stream.getvalue()) self.assertTrue('>' in self.stream.getvalue()) self.assertFalse(' ' in self.stream.getvalue()) self.assertFalse('<' in self.stream.getvalue()) self.assertFalse('>' in self.stream.getvalue())
def test_reportOutcomeVerbose(self, mock_proto_test): """ _reportOutcome contains output we expect in verbose mode. """ mockProtoTest = MagicMock() mockProtoTest.getDescription.return_value = "a description" mock_proto_test.return_value = mockProtoTest self.args.verbose = 2 def isatty(): return True gs = GreenStream(self.stream) gs.isatty = isatty gtr = GreenTestResult(self.args, gs) r = "a fake reason" t = MagicMock() t.__str__.return_value = "junk" gtr._reportOutcome(t, ".", lambda x: x, None, r) self.assertIn(r, self.stream.getvalue())
def test_reportOutcomeCursorUp(self, mock_proto_test): """ _reportOutcome moves the cursor up when it needs to. """ mockProtoTest = MagicMock() mockProtoTest.getDescription.return_value = "a description" mock_proto_test.return_value = mockProtoTest self.args.verbose = 2 def isatty(): return True gs = GreenStream(self.stream) gs.isatty = isatty gtr = GreenTestResult(self.args, gs) r = "a fake reason" t = MagicMock() t.__str__.return_value = "x" * 1000 gtr._reportOutcome(t, ".", lambda x: x, None, r) self.assertIn(r, self.stream.getvalue()) self.assertLess(len(self.stream.getvalue()), 2000)