File: test_xml_parsers.py

package info (click to toggle)
python-ete3 3.1.2%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 14,148 kB
  • sloc: python: 52,375; javascript: 12,959; xml: 4,903; ansic: 69; sql: 65; makefile: 26; sh: 7
file content (63 lines) | stat: -rw-r--r-- 2,131 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
from __future__ import absolute_import
from __future__ import print_function
import unittest
import os
import time
from .. import nexml, phyloxml

ETEPATH = os.path.abspath(os.path.split(os.path.realpath(__file__))[0]+'/../../')

class Test_PhyloXML(unittest.TestCase):
    def test_phyloxml_parser(self):
        path = os.path.join(ETEPATH, "examples/phyloxml/")
        for fname in os.listdir(path):
            if fname.endswith(".xml"):
                W = open("/tmp/test_xml_parser", "w")
                print(fname, "...", end=' ')
                fpath = os.path.join(path, fname)
                p = phyloxml.Phyloxml()
                t1 = time.time()
                p.build_from_file(fpath)
                etime = time.time()-t1
                print("%0.1f secs" %(etime))
                p.export(outfile = W)

    def test_examples(self):
        path = os.path.join(ETEPATH, "examples/phyloxml/")
        for ex in os.listdir(path):
            print("testing", ex)
            if ex.endswith(".py"):
                s = os.system("cd %s && python %s" %(path, ex))
                if s:
                    raise Exception("Example crashed!")



class Test_NeXML(unittest.TestCase):
    def test_nexml_parser(self):
        path = os.path.join(ETEPATH, "examples/nexml/")
        for fname in os.listdir(path):
            if fname.endswith(".xml"):
                W = open("/tmp/test_xml_parser", "w")
                print(fname, "...", end=' ')
                fpath = os.path.join(path, fname)
                p = nexml.Nexml()
                t1 = time.time()
                p.build_from_file(fpath)
                etime = time.time()-t1
                print("%0.1f secs" %(etime))
                p.export(outfile = W)

    def test_examples(self):
        path = os.path.join(ETEPATH, "examples/nexml/")
        for ex in os.listdir(path):
            print("testing", ex)
            if ex.endswith(".py"):
                s = os.system("cd %s && python %s" %(path, ex))
                if s:
                    raise Exception("Example crashed!")



if __name__ == '__main__':
    unittest.main()