コード例 #1
0
    def test_same_test_appears_twice(self):
        """If the same test appears twice, its information should be appended.

        This is not the typical, expected layout of the file, but it should be handled
        correctly in case the file is written this way.
        """
        contents = """<?xml version= "1.0"?>
<expectedFails version="1.1">
  <test name="my.test.1">
    <phase name="RUN">
      <status>FAIL</status>
      <issue>#404</issue>
    </phase>
  </test>
  <test name="my.test.1">
    <phase name="COMPARE_base_rest">
      <status>PEND</status>
      <issue>#404</issue>
      <comment>Because of the RUN failure, this phase is listed as PEND</comment>
    </phase>
  </test>
</expectedFails>
"""
        with open(self._xml_filepath, "w") as xml_file:
            xml_file.write(contents)
        expected_fails_file = ExpectedFailsFile(self._xml_filepath)
        xfails = expected_fails_file.get_expected_fails()

        expected_test1 = ExpectedFails()
        expected_test1.add_failure("RUN", "FAIL")
        expected_test1.add_failure("COMPARE_base_rest", "PEND")
        expected = {"my.test.1": expected_test1}

        self.assertEqual(xfails, expected)
コード例 #2
0
    def test_same_test_appears_twice(self):
        """If the same test appears twice, its information should be appended.

        This is not the typical, expected layout of the file, but it should be handled
        correctly in case the file is written this way.
        """
        contents = """<?xml version= "1.0"?>
<expectedFails version="1.1">
  <test name="my.test.1">
    <phase name="RUN">
      <status>FAIL</status>
      <issue>#404</issue>
    </phase>
  </test>
  <test name="my.test.1">
    <phase name="COMPARE_base_rest">
      <status>PEND</status>
      <issue>#404</issue>
      <comment>Because of the RUN failure, this phase is listed as PEND</comment>
    </phase>
  </test>
</expectedFails>
"""
        with open(self._xml_filepath, 'w') as xml_file:
            xml_file.write(contents)
        expected_fails_file = ExpectedFailsFile(self._xml_filepath)
        xfails = expected_fails_file.get_expected_fails()

        expected_test1 = ExpectedFails()
        expected_test1.add_failure('RUN', 'FAIL')
        expected_test1.add_failure('COMPARE_base_rest', 'PEND')
        expected = {'my.test.1': expected_test1}

        self.assertEqual(xfails, expected)
コード例 #3
0
def _get_xfails(expected_fails_filepath):
    """Returns a dictionary of ExpectedFails objects, where the keys are test names

    expected_fails_filepath should be either a string giving the path to
    the file containing expected failures, or None. If None, then this
    returns an empty dictionary (as if expected_fails_filepath were
    pointing to a file with no expected failures listed).
    """
    if expected_fails_filepath is not None:
        expected_fails_file = ExpectedFailsFile(expected_fails_filepath)
        xfails = expected_fails_file.get_expected_fails()
    else:
        xfails = {}
    return xfails
コード例 #4
0
ファイル: cs_status.py プロジェクト: fischer-ncar/cime
def _get_xfails(expected_fails_filepath):
    """Returns a dictionary of ExpectedFails objects, where the keys are test names

    expected_fails_filepath should be either a string giving the path to
    the file containing expected failures, or None. If None, then this
    returns an empty dictionary (as if expected_fails_filepath were
    pointing to a file with no expected failures listed).
    """
    if expected_fails_filepath is not None:
        expected_fails_file = ExpectedFailsFile(expected_fails_filepath)
        xfails = expected_fails_file.get_expected_fails()
    else:
        xfails = {}
    return xfails
コード例 #5
0
    def test_basic(self):
        """Basic test of the parsing of an expected fails file"""
        contents = """<?xml version= "1.0"?>
<expectedFails version="1.1">
  <test name="my.test.1">
    <phase name="RUN">
      <status>FAIL</status>
      <issue>#404</issue>
    </phase>
    <phase name="COMPARE_base_rest">
      <status>PEND</status>
      <issue>#404</issue>
      <comment>Because of the RUN failure, this phase is listed as PEND</comment>
    </phase>
  </test>
  <test name="my.test.2">
    <phase name="GENERATE">
      <status>FAIL</status>
      <issue>ESMCI/cime#2917</issue>
    </phase>
    <phase name="BASELINE">
      <status>FAIL</status>
      <issue>ESMCI/cime#2917</issue>
    </phase>
  </test>
</expectedFails>
"""
        with open(self._xml_filepath, 'w') as xml_file:
            xml_file.write(contents)
        expected_fails_file = ExpectedFailsFile(self._xml_filepath)
        xfails = expected_fails_file.get_expected_fails()

        expected_test1 = ExpectedFails()
        expected_test1.add_failure('RUN', 'FAIL')
        expected_test1.add_failure('COMPARE_base_rest', 'PEND')
        expected_test2 = ExpectedFails()
        expected_test2.add_failure('GENERATE', 'FAIL')
        expected_test2.add_failure('BASELINE', 'FAIL')
        expected = {'my.test.1': expected_test1,
                    'my.test.2': expected_test2}

        self.assertEqual(xfails, expected)
コード例 #6
0
    def test_invalid_file(self):
        """Given an invalid file, an exception should be raised in schema validation"""

        # This file is missing a <status> element in the <phase> block.
        #
        # It's important to have the expectedFails version number be greater than 1,
        # because schema validation isn't done in cime for files with a version of 1.
        contents = """<?xml version= "1.0"?>
<expectedFails version="1.1">
  <test name="my.test.1">
    <phase name="RUN">
    </phase>
  </test>
</expectedFails>
"""
        with open(self._xml_filepath, "w") as xml_file:
            xml_file.write(contents)

        with six.assertRaisesRegex(self, CIMEError, "Schemas validity error"):
            _ = ExpectedFailsFile(self._xml_filepath)