def test_writeQuakeML(self): """ Tests writing a QuakeML document. """ with NamedTemporaryFile() as tf: tmpfile = tf.name writeQuakeML(self.catalog, tmpfile, validate=IS_RECENT_LXML) # Read file again. Avoid the (legit) warning about the already used # resource identifiers. with warnings.catch_warnings(record=True): warnings.simplefilter("ignore") catalog2 = readQuakeML(tmpfile) self.assertTrue(len(catalog2), 1)
def test_writeQuakeML(self): """ Tests writing a QuakeML document. """ filename = os.path.join(self.path, 'qml-example-1.2-RC3.xml') with NamedTemporaryFile() as tf: tmpfile = tf.name catalog = readQuakeML(filename) self.assertTrue(len(catalog), 1) writeQuakeML(catalog, tmpfile) # Read file again. Avoid the (legit) warning about the already used # resource identifiers. with warnings.catch_warnings(record=True): warnings.simplefilter("ignore") catalog2 = readQuakeML(tmpfile) self.assertTrue(len(catalog2), 1)
def test_writeQuakeML(self): """ Tests writing a QuakeML document. """ filename = os.path.join(self.path, 'qml-example-1.2-RC3.xml') with NamedTemporaryFile() as tf: tmpfile = tf.name catalog = readQuakeML(filename) self.assertTrue(len(catalog), 1) writeQuakeML(catalog, tmpfile, validate=True) # Read file again. Avoid the (legit) warning about the already used # resource identifiers. with warnings.catch_warnings(record=True): warnings.simplefilter("ignore") catalog2 = readQuakeML(tmpfile) self.assertTrue(len(catalog2), 1)
def test_writeQuakeML(self): """ Tests writing a QuakeML document. skipIfPython25 due to the use of the warnings context manager. """ filename = os.path.join(self.path, 'qml-example-1.2-RC3.xml') tmpfile = NamedTemporaryFile().name catalog = readQuakeML(filename) self.assertTrue(len(catalog), 1) writeQuakeML(catalog, tmpfile) # Read file again. Avoid the (legit) warning about the already used # resource identifiers. with warnings.catch_warnings(record=True): warnings.simplefilter("ignore") catalog2 = readQuakeML(tmpfile) self.assertTrue(len(catalog2), 1) # clean up os.remove(tmpfile)