Beispiel #1
0
 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())
Beispiel #2
0
 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())
Beispiel #3
0
 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())
Beispiel #4
0
 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())
Beispiel #5
0
 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 &nbsp; <>'
     gtr._reportOutcome(t, '.', lambda x: x, None, r)
     self.assertTrue(r in self.stream.getvalue())
     self.assertTrue('&amp;' in self.stream.getvalue())
     self.assertTrue('&lt;' in self.stream.getvalue())
     self.assertTrue('&gt;' in self.stream.getvalue())
     self.assertFalse('&nbsp;' in self.stream.getvalue())
     self.assertFalse('<' in self.stream.getvalue())
     self.assertFalse('>' in self.stream.getvalue())
Beispiel #6
0
 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())
Beispiel #7
0
 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)
Beispiel #8
0
 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)
Beispiel #9
0
 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 &nbsp; <>'
     t = proto_test(Injection('test_method'))
     gtr._reportOutcome(t, '.', lambda x: x, None, r)
     self.assertTrue(r in self.stream.getvalue())
     self.assertTrue('&amp;' in self.stream.getvalue())
     self.assertTrue('&lt;' in self.stream.getvalue())
     self.assertTrue('&gt;' in self.stream.getvalue())
     self.assertFalse('&nbsp;' in self.stream.getvalue())
     self.assertFalse('<' in self.stream.getvalue())
     self.assertFalse('>' in self.stream.getvalue())
Beispiel #10
0
    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())
Beispiel #11
0
    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)