Пример #1
0
 def _readData(self):
   """
     Read data from VO table
   """
   # Temporarily suppress warnings (astropy issues one on reading this table)
   with warnings.catch_warnings():
     warnings.simplefilter("ignore")
     try:
       self.vot = votable.parse(self._fs.requestFile(self.dataFileName, 'r', gzip.open), pedantic=False, invalid="mask")
     except Exception as e:
       votable.validate(self._fs.requestFile(self.dataFileName, 'r', gzip.open))
       raise e
   # Use 'name' over ID field to specify column names
   self.vot = self.vot.get_first_table().to_table(use_names_over_ids=True)
Пример #2
0
 def _readData(self):
     """
       Read data from VO table
     """
     # Temporarily suppress warnings (astropy issues one on reading this table)
     with warnings.catch_warnings():
         warnings.simplefilter("ignore")
         try:
             self.vot = votable.parse(self._fs.requestFile(
                 self.dataFileName, 'r', gzip.open), pedantic=False, invalid="mask")
         except Exception as e:
             votable.validate(self._fs.requestFile(
                 self.dataFileName, 'r', gzip.open))
             raise e
     # Use 'name' over ID field to specify column names
     self.vot = self.vot.get_first_table().to_table(use_names_over_ids=True)
Пример #3
0
def test_validate_output_invalid():
    """
    Issue #12603. Test that we get the correct output from votable.validate with an invalid
    votable.
    """

    # A votable with errors
    invalid_votable_filepath = get_pkg_data_filename('data/regression.xml')

    # When output is None, check that validate returns validation output as a string
    validate_out = validate(invalid_votable_filepath, output=None)
    assert isinstance(validate_out, str)
    # Check for known error string
    assert "E02: Incorrect number of elements in array." in validate_out

    # When output is not set, check that validate returns a bool
    validate_out = validate(invalid_votable_filepath)
    assert isinstance(validate_out, bool)
    # Check that validation output is correct (votable is not valid)
    assert validate_out is False
Пример #4
0
def test_validate_output_valid():
    """
    Issue #12603. Test that we get the correct output from votable.validate with a valid
    votable
    """

    # A valid votable. (Example from the votable standard:
    # https://www.ivoa.net/documents/VOTable/20191021/REC-VOTable-1.4-20191021.html )
    valid_votable_filepath = get_pkg_data_filename('data/valid_votable.xml')

    # When output is None, check that validate returns validation output as a string
    validate_out = validate(valid_votable_filepath, output=None)
    assert isinstance(validate_out, str)
    # Check for known good output string
    assert "astropy.io.votable found no violations" in validate_out

    # When output is not set, check that validate returns a bool
    validate_out = validate(valid_votable_filepath)
    assert isinstance(validate_out, bool)
    # Check that validation output is correct (votable is valid)
    assert validate_out is True