當前位置: 首頁>>代碼示例>>Python>>正文


Python TestHelper.assertConsoleOutput方法代碼示例

本文整理匯總了Python中releng.test.utils.TestHelper.assertConsoleOutput方法的典型用法代碼示例。如果您正苦於以下問題:Python TestHelper.assertConsoleOutput方法的具體用法?Python TestHelper.assertConsoleOutput怎麽用?Python TestHelper.assertConsoleOutput使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在releng.test.utils.TestHelper的用法示例。


在下文中一共展示了TestHelper.assertConsoleOutput方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: TestStatusReporterNoPropagate

# 需要導入模塊: from releng.test.utils import TestHelper [as 別名]
# 或者: from releng.test.utils.TestHelper import assertConsoleOutput [as 別名]
class TestStatusReporterNoPropagate(unittest.TestCase):
    def setUp(self):
        env = {
                'STATUS_FILE': 'logs/status.json',
                'NO_PROPAGATE_FAILURE': '1'
            }
        self.helper = TestHelper(self, workspace='ws', env=env)

    def test_Failure(self):
        with self.helper.factory.status_reporter as status_reporter:
            status_reporter.mark_failed('Failure reason')
        self.assertFalse(self.helper.executor.exit.called)
        self.helper.assertConsoleOutput("""\
                Build FAILED:
                  Failure reason
                """)
        self.helper.assertOutputJsonFile('ws/logs/status.json', {
                'result': 'FAILURE',
                'reason': 'Failure reason'
            })

    def test_Aborted(self):
        with self.helper.factory.status_reporter as status_reporter:
            raise AbortError(143)
        self.assertFalse(self.helper.executor.exit.called)
        self.helper.assertOutputJsonFile('ws/logs/status.json', {
                'result': 'ABORTED',
                'reason': None
            })
開發者ID:,項目名稱:,代碼行數:31,代碼來源:

示例2: TestStatusReporterJson

# 需要導入模塊: from releng.test.utils import TestHelper [as 別名]
# 或者: from releng.test.utils.TestHelper import assertConsoleOutput [as 別名]
class TestStatusReporterJson(unittest.TestCase):
    def setUp(self):
        env = {
                'STATUS_FILE': 'logs/status.json'
            }
        self.helper = TestHelper(self, workspace='ws', env=env)

    def test_Success(self):
        with self.helper.factory.status_reporter as status_reporter:
            self.assertFalse(status_reporter.failed)
        self.assertFalse(status_reporter.failed)
        self.helper.assertConsoleOutput('')
        self.helper.assertOutputJsonFile('ws/logs/status.json', {
                'result': 'SUCCESS',
                'reason': None
            })

    def test_Failure(self):
        with self.helper.factory.status_reporter as status_reporter:
            status_reporter.mark_failed('Failure reason')
        self.helper.executor.exit.assert_called_with(1)
        self.helper.assertConsoleOutput("""\
                Build FAILED:
                  Failure reason
                """)
        self.helper.assertOutputJsonFile('ws/logs/status.json', {
                'result': 'FAILURE',
                'reason': 'Failure reason'
            })

    def test_Unstable(self):
        with self.helper.factory.status_reporter as status_reporter:
            status_reporter.mark_unstable('Unstable reason')
        self.assertFalse(self.helper.executor.exit.called)
        self.helper.assertConsoleOutput("""\
                FAILED: Unstable reason
                Build FAILED:
                  Unstable reason
                """)
        self.helper.assertOutputJsonFile('ws/logs/status.json', {
                'result': 'UNSTABLE',
                'reason': 'Unstable reason'
            })

    def test_Aborted(self):
        with self.helper.factory.status_reporter as status_reporter:
            raise AbortError(143)
        self.assertFalse(status_reporter.failed)
        self.helper.executor.exit.assert_called_with(143)
        self.helper.assertConsoleOutput('')
        self.helper.assertOutputJsonFile('ws/logs/status.json', {
                'result': 'ABORTED',
                'reason': None
            })
開發者ID:,項目名稱:,代碼行數:56,代碼來源:

示例3: TestStatusReporter

# 需要導入模塊: from releng.test.utils import TestHelper [as 別名]
# 或者: from releng.test.utils.TestHelper import assertConsoleOutput [as 別名]
class TestStatusReporter(unittest.TestCase):
    def setUp(self):
        self.helper = TestHelper(self, workspace='ws')

    def test_Success(self):
        with self.helper.factory.status_reporter as status_reporter:
            self.assertFalse(status_reporter.failed)
        self.assertFalse(status_reporter.failed)
        self.assertEqual(self.helper.executor.mock_calls,
                [mock.call.remove_path('logs/unsuccessful-reason.log')])
        self.helper.assertConsoleOutput('')

    def test_Failure(self):
        with self.helper.factory.status_reporter as status_reporter:
            status_reporter.mark_failed('Failure reason')
            self.assertTrue(status_reporter.failed)
        self.helper.assertConsoleOutput("""\
                Build FAILED:
                  Failure reason
                """)
        self.helper.assertOutputFile('ws/logs/unsuccessful-reason.log',
                """\
                Failure reason
                """)

    def test_Unstable(self):
        with self.helper.factory.status_reporter as status_reporter:
            status_reporter.mark_unstable('Unstable reason')
            self.assertFalse(status_reporter.failed)
        self.helper.assertConsoleOutput("""\
                FAILED: Unstable reason
                Build FAILED:
                  Unstable reason
                """)
        self.helper.assertOutputFile('ws/logs/unsuccessful-reason.log',
                """\
                Unstable reason
                """)

    def test_BuildError(self):
        self.helper.factory.init_status_reporter(tracebacks=False)
        with self.helper.factory.status_reporter:
            raise BuildError('Mock build error')
        self.assertTrue(self.helper.factory.status_reporter.failed)
        self.helper.assertConsoleOutput("""\
                BuildError: Mock build error
                Build FAILED:
                  Mock build error
                """)
        self.helper.assertOutputFile('ws/logs/unsuccessful-reason.log',
                """\
                Mock build error
                """)

    def test_OtherError(self):
        self.helper.factory.init_status_reporter(tracebacks=False)
        with self.assertRaises(ValueError):
            with self.helper.factory.status_reporter:
                raise ValueError('Mock Python error')
        self.helper.assertConsoleOutput('')
        self.helper.assertOutputFile('ws/logs/unsuccessful-reason.log',
                """\
                ValueError: Mock Python error
                """)

    def test_Aborted(self):
        with self.helper.factory.status_reporter as status_reporter:
            raise AbortError(143)
        self.assertFalse(status_reporter.failed)
        self.assertEqual(self.helper.executor.mock_calls,
                [mock.call.remove_path('logs/unsuccessful-reason.log'),
                 mock.call.exit(143)])
        self.helper.assertConsoleOutput('')

    def test_AbortedAfterFailure(self):
        with self.helper.factory.status_reporter as status_reporter:
            status_reporter.mark_failed('Failure reason')
            raise AbortError(143)
        self.assertTrue(status_reporter.failed)
        self.assertEqual(self.helper.executor.mock_calls,
                [mock.call.remove_path('logs/unsuccessful-reason.log'),
                 mock.call.exit(143)])
        self.helper.assertConsoleOutput('')
開發者ID:,項目名稱:,代碼行數:85,代碼來源:


注:本文中的releng.test.utils.TestHelper.assertConsoleOutput方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。