diff --git a/tests/test_xmlparsing.py b/tests/test_xmlparsing.py index 70d8c792af781d95c36b20b075a5382ef019b70c..bb3207dd5f87d3f90fb894fc729a0124e5d164c4 100644 --- a/tests/test_xmlparsing.py +++ b/tests/test_xmlparsing.py @@ -140,20 +140,22 @@ def test_container_xml(tmp_path): For issue 89: https://gitlab.com/caosdb/caosdb-pylib/-/issues/89 """ - with warnings.catch_warnings(): - - # Create XML with container with one RecordType. - db.RecordType(name="TestRT").insert() - cont = db.execute_query("FIND RecordType TestRT") - xml_file = os.path.join(tmp_path, "tmp.xml") - with open(xml_file, "w", encoding="utf-8") as opened: - opened.write(str(cont)) - - # Read from file again. - with open(xml_file, "r", encoding="utf-8") as opened: - xml_str = opened.read() + # Create XML with container with one RecordType. + db.RecordType(name="TestRT").insert() + cont = db.execute_query("FIND RecordType TestRT") + xml_file = os.path.join(tmp_path, "tmp.xml") + with open(xml_file, "w", encoding="utf-8") as opened: + opened.write(str(cont)) + + # Read from file again. + with open(xml_file, "r", encoding="utf-8") as opened: + xml_str = opened.read() + with warnings.catch_warnings(record=True) as raised_warnings: cont_restored = db.Container.from_xml(xml_str) + assert not raised_warnings, ( + f"Loading from xml did not run smoothly.\n{raised_warnings[0].message}" + ) - # Test if the serialization and deserialization worked. - assert cont[0].id == cont_restored[0].id - assert cont[0].name == cont_restored[0].name + # Test if the serialization and deserialization worked. + assert cont[0].id == cont_restored[0].id + assert cont[0].name == cont_restored[0].name