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


Python TestHelper.assertOutputFile方法代碼示例

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


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

示例1: TestStatusReporter

# 需要導入模塊: from releng.test.utils import TestHelper [as 別名]
# 或者: from releng.test.utils.TestHelper import assertOutputFile [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,代碼來源:

示例2: TestRunBuild

# 需要導入模塊: from releng.test.utils import TestHelper [as 別名]
# 或者: from releng.test.utils.TestHelper import assertOutputFile [as 別名]
class TestRunBuild(unittest.TestCase):
    def setUp(self):
        self.helper = TestHelper(self)
        self.helper.add_input_file("Testing/TAG", """\
                YYYYMMDD-HHMM
                Experimental
                """)

    def test_CTestSuccess(self):
        self.helper.add_input_file("Testing/YYYYMMDD-HHMM/Test.xml", """\
                <Site>
                  <Testing>
                    <Test Status="passed">
                      <Name>Test1</Name>
                      <Results>
                        <NamedMeasurement name="Execution Time">
                          <Value>0.1</Value>
                        </NamedMeasurement>
                        <Measurement>
                          <Value>some output</Value>
                        </Measurement>
                      </Results>
                    </Test>
                  </Testing>
                </Site>
                """)
        process_ctest_xml(self.helper.executor, memcheck=False)
        self.helper.assertOutputFile("Testing/Temporary/CTest.xml", """\
                <testsuites><testsuite name="CTest"><testcase classname="CTest" name="Test1" time="0.1"><system-out>some output</system-out></testcase></testsuite></testsuites>""")

    def test_CTestFailure(self):
        self.helper.add_input_file("Testing/YYYYMMDD-HHMM/Test.xml", """\
                <Site>
                  <Testing>
                    <Test Status="failed">
                      <Name>Test1</Name>
                      <Results>
                        <NamedMeasurement name="Exit Code">
                          <Value>Failed</Value>
                        </NamedMeasurement>
                        <NamedMeasurement name="Execution Time">
                          <Value>0.1</Value>
                        </NamedMeasurement>
                        <Measurement>
                          <Value>some output</Value>
                        </Measurement>
                      </Results>
                    </Test>
                  </Testing>
                </Site>
                """)
        process_ctest_xml(self.helper.executor, memcheck=False)
        self.helper.assertOutputFile("Testing/Temporary/CTest.xml", """\
                <testsuites><testsuite name="CTest"><testcase classname="CTest" name="Test1" time="0.1"><failure message="Failed" /><system-out>some output</system-out></testcase></testsuite></testsuites>""")

    def test_CTestAsanFailure(self):
        self.helper.add_input_file("Testing/YYYYMMDD-HHMM/DynamicAnalysis.xml", """\
                <Site>
                  <DynamicAnalysis>
                    <Test Status="failed">
                      <Name>Test1</Name>
                      <Results>
                        <Defect type="SEGV">1</Defect>
                      </Results>
                      <Log>some output</Log>
                    </Test>
                  </DynamicAnalysis>
                </Site>
                """)
        process_ctest_xml(self.helper.executor, memcheck=True)
        self.helper.assertOutputFile("Testing/Temporary/CTest.xml", """\
                <testsuites><testsuite name="CTest_MemCheck"><testcase classname="CTest_MemCheck" name="Test1"><failure message="SEGV" /><system-out>some output</system-out></testcase></testsuite></testsuites>""")
開發者ID:gromacs,項目名稱:releng,代碼行數:74,代碼來源:test_cmake.py


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