Repository: biopython/biopython

Issue:
SeqXML parser broken
### Setup

I am reporting a problem with Biopython version, Python version, and operating
system as follows:

```python
import sys; print(sys.version)
import platform; print(platform.python_implementation()); print(platform.platform())
import Bio; print(Bio.__version__)
```

CPython
Darwin-19.6.0-x86_64-i386-64bit
1.79.dev0


In `test_SeqIO_SeqXML.py`:

```python
def assert_equal_records(testCase, record_a, record_b):
    testCase.assertEqual(record_a.id, record_b.id)
    testCase.assertEqual(record_a.name, record_b.name)
    testCase.assertEqual(record_a.description, record_b.description)
    testCase.assertEqual(str(record_a.seq), str(record_b.seq))
    testCase.assertEqual(record_a.dbxrefs, record_b.dbxrefs)
    testCase.assertEqual(record_a.annotations, record_a.annotations)
```

The last line compares `record_a` to `record_a` instead of to `record_b`.
Fixing this line causes the test to fail.


Discussion:

Resolving patch:
diff --git a/Bio/SeqIO/SeqXmlIO.py b/Bio/SeqIO/SeqXmlIO.py
--- a/Bio/SeqIO/SeqXmlIO.py
+++ b/Bio/SeqIO/SeqXmlIO.py
@@ -653,12 +653,14 @@ def _write_properties(self, record):
                 elif isinstance(value, list):
 
                     for v in value:
-                        if isinstance(value, (int, float, str)):
-                            attr = {"name": key, "value": v}
-                            self.xml_generator.startElement(
-                                "property", AttributesImpl(attr)
-                            )
-                            self.xml_generator.endElement("property")
+                        if v is None:
+                            attr = {"name": key}
+                        else:
+                            attr = {"name": key, "value": str(v)}
+                        self.xml_generator.startElement(
+                            "property", AttributesImpl(attr)
+                        )
+                        self.xml_generator.endElement("property")
 
                 elif isinstance(value, (int, float, str)):
 


Test patch:
diff --git a/Tests/test_SeqIO_SeqXML.py b/Tests/test_SeqIO_SeqXML.py
--- a/Tests/test_SeqIO_SeqXML.py
+++ b/Tests/test_SeqIO_SeqXML.py
@@ -13,15 +13,6 @@
 from io import BytesIO
 
 
-def assert_equal_records(testCase, record_a, record_b):
-    testCase.assertEqual(record_a.id, record_b.id)
-    testCase.assertEqual(record_a.name, record_b.name)
-    testCase.assertEqual(record_a.description, record_b.description)
-    testCase.assertEqual(str(record_a.seq), str(record_b.seq))
-    testCase.assertEqual(record_a.dbxrefs, record_b.dbxrefs)
-    testCase.assertEqual(record_a.annotations, record_a.annotations)
-
-
 class TestSimpleRead(unittest.TestCase):
     def test_check_SeqIO(self):
         """Files readable using parser via SeqIO."""
@@ -196,7 +187,12 @@ def _write_parse_and_compare(self, read1_records):
         self.assertEqual(len(read1_records), len(read2_records))
 
         for record1, record2 in zip(read1_records, read2_records):
-            assert_equal_records(self, record1, record2)
+            self.assertEqual(record1.id, record2.id)
+            self.assertEqual(record1.name, record2.name)
+            self.assertEqual(record1.description, record2.description)
+            self.assertEqual(record1.seq, record2.seq)
+            self.assertEqual(record1.dbxrefs, record2.dbxrefs)
+            self.assertEqual(record1.annotations, record2.annotations)
 
     def test_write_species(self):
         """Test writing species from annotation tags."""