Skip to content

Commit

Permalink
Fix #9 reading all SBGN test files
Browse files Browse the repository at this point in the history
  • Loading branch information
matthiaskoenig committed Nov 28, 2016
1 parent f68fb74 commit 84df286
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 6 deletions.
2 changes: 1 addition & 1 deletion libsbgnpy/libsbgn.py
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ def getSubclassFromModule_(module, class_):
# Globals
#

ExternalEncoding = 'ascii'
ExternalEncoding = 'utf8'
Tag_pattern_ = re_.compile(r'({.*})?(.*)')
String_cleanup_pat_ = re_.compile(r"[\n\r\s]+")
Namespace_extract_pat_ = re_.compile(r'{(.*)}(.*)')
Expand Down
1 change: 1 addition & 0 deletions libsbgnpy/tests/test_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

dir = os.path.dirname(os.path.realpath(__file__))


class ExampleTestCase(unittest.TestCase):

def test_read_examples(self):
Expand Down
46 changes: 41 additions & 5 deletions libsbgnpy/tests/test_testfiles.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,52 @@
import unittest

#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Read all the test files.
"""
# TODO: implement

from __future__ import print_function
import unittest
import os
import libsbgnpy.libsbgn as libsbgn
from libsbgnpy.libsbgnTypes import Language, GlyphClass, ArcClass, Orientation

class MyTestCase(unittest.TestCase):
##############################################
# Test files
##############################################
dir = os.path.dirname(os.path.realpath(__file__))
testfile_dir = os.path.join(dir, 'test-files')

def find_sbgn_files(dir):
sbgn_files = []
for root, dirs, files in os.walk(dir):
for file in files:
if file.endswith(".sbgn"):
f = os.path.join(root, file)
sbgn_files.append(f)
return sbgn_files

sbgn_files = find_sbgn_files(dir=testfile_dir)
##############################################


class TestSBGNFile(unittest.TestCase):
pass

def create_method(f):
def f_expected(self):
print('*' * 80)
print(f)
print('*' * 80)
sbgn = libsbgn.parse(f)
self.assertTrue(sbgn is not None)
return f_expected

# Add test functions for files
for k, f in enumerate(sbgn_files):
test_method = create_method(f)
test_method.__name__ = 'test_%s' % k
setattr(TestSBGNFile, test_method.__name__, test_method)
del test_method

if __name__ == '__main__':

unittest.main()

0 comments on commit 84df286

Please sign in to comment.