Beispiel #1
0
 def test_019_to_etree(self):
     cmdTempl = (
         'python generateDS.py --no-dates --no-versions '
         '--silence --member-specs=list -f '
         '-o tests/%s2_sup.py -s tests/%s2_sub.py '
         '--export="etree" --silence '
         '--super=%s2_sup '
         'tests/%s.xsd'
     )
     t_ = 'to_etree'
     cmd = cmdTempl % (t_, t_, t_, t_, )
     self.executeClean(cmd, cwd='..')
     self.compareFiles(
         '{}1_sup.py'.format(t_),
         '{}2_sup.py'.format(t_),
         ('sys.stdout.write',))
     self.compareFiles('{}1_sub.py'.format(t_), '{}2_sub.py'.format(t_))
     import to_etree2_sup
     rootObj, rootElement, mapping, reverse_mapping = \
         to_etree2_sup.parseEtree('to_etree.xml')
     content = etree.tostring(
         rootElement, pretty_print=True,
         xml_declaration=True, encoding="utf-8")
     outfile = open('to_etree2.xml', 'w')
     outfile.write(content)
     outfile.close()
     self.compareFiles('{}1.xml'.format(t_), '{}2.xml'.format(t_))
     # cleanup generated files
     self.remove('{}2_sup.py'.format(t_))
     self.remove('{}2_sub.py'.format(t_))
     self.remove('{}2.xml'.format(t_))
Beispiel #2
0
 def test_019_to_etree(self):
     cmdTempl = (
         'python generateDS.py --no-dates --no-versions '
         '--silence --member-specs=list -f '
         '-o tests/%s2_sup.py -s tests/%s2_sub.py '
         '--export="etree" --silence '
         '--super=%s2_sup '
         'tests/%s.xsd'
     )
     t_ = 'to_etree'
     cmd = cmdTempl % (t_, t_, t_, t_, )
     result, _ = self.execute(cmd, cwd='..')
     cmd = 'diff %s1_sup.py %s2_sup.py' % (t_, t_, )
     result, err = self.execute(cmd)
     self.check_result(result, err, ('sys.stdout.write',))
     cmd = 'diff %s1_sub.py %s2_sub.py' % (t_, t_, )
     result, err = self.execute(cmd)
     self.check_result(result, err, ())
     import to_etree2_sup
     rootObj, rootElement, mapping, reverse_mapping = \
         to_etree2_sup.parseEtree('to_etree.xml')
     content = etree.tostring(
         rootElement, pretty_print=True,
         xml_declaration=True, encoding="utf-8")
     outfile = open('to_etree2.xml', 'w')
     outfile.write(content)
     outfile.close()
     cmd = 'diff %s1.xml %s2.xml' % (t_, t_, )
     result, err = self.execute(cmd)
     self.check_result(result, err, ())
Beispiel #3
0
 def test_019_to_etree(self):
     cmdTempl = ('python generateDS.py --no-dates --no-versions '
                 '--silence --member-specs=list -f '
                 '-o tests/%s2_sup.py -s tests/%s2_sub.py '
                 '--export="etree" --silence '
                 '--super=%s2_sup '
                 'tests/%s.xsd')
     t_ = 'to_etree'
     cmd = cmdTempl % (
         t_,
         t_,
         t_,
         t_,
     )
     result, _ = self.execute(cmd, cwd='..')
     cmd = 'diff %s1_sup.py %s2_sup.py' % (
         t_,
         t_,
     )
     result, err = self.execute(cmd)
     self.check_result(result, err, ('sys.stdout.write', ))
     cmd = 'diff %s1_sub.py %s2_sub.py' % (
         t_,
         t_,
     )
     result, err = self.execute(cmd)
     self.check_result(result, err, ())
     import to_etree2_sup
     rootObj, rootElement, mapping, reverse_mapping = \
         to_etree2_sup.parseEtree('to_etree.xml')
     content = etree.tostring(rootElement,
                              pretty_print=True,
                              xml_declaration=True,
                              encoding="utf-8")
     outfile = open('to_etree2.xml', 'w')
     outfile.write(content)
     outfile.close()
     cmd = 'diff %s1.xml %s2.xml' % (
         t_,
         t_,
     )
     result, err = self.execute(cmd)
     self.check_result(result, err, ())