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()
|