human
Complete this python program:
def _test_write_factory(source):
assistant
#Here is the Python program you requested.

    """Tests for serialization of objects to NeXML format.
    Modifies the globally defined filenames in order to run the other parser
    tests on files (re)generated by NeXMLIO\s own writer.
    """
    filename = os.path.join('NeXML/', source)
    def test_write(self):
        'Parse,    rewrite    and    retest    an    example    file.'
        with open(filename, 'rb') as infile:
            t1 = next(NeXMLIO.Parser(infile).parse())
        with open(DUMMY, 'w+b') as outfile:
            NeXMLIO.write([t1], outfile)
        with open(DUMMY, 'rb') as infile:
            t2 = next(NeXMLIO.Parser(infile).parse())
        def assert_property(prop_name):
            p1 = sorted([getattr(n, prop_name) for n in t1.get_terminals() if getattr(n, prop_name)])
            p2 = sorted([getattr(n, prop_name) for n in t2.get_terminals() if getattr(n, prop_name)])
            self.assertEqual(p1, p2)
        for prop_name in ('name', 'branch_length', 'confidence'):
            assert_property(prop_name)
    test_write.__doc__ = ('Write    and    re-parse    the    phylogenies    in    %s.' % source)
    return test_write