summaryrefslogtreecommitdiff
path: root/test-chill/unit-tests/test__extract.py
diff options
context:
space:
mode:
authorDerick Huth <derickhuth@gmail.com>2014-10-06 12:42:34 -0600
committerDerick Huth <derickhuth@gmail.com>2014-10-06 12:42:34 -0600
commit8d73c8fcc75556c1df71dd39dd99783f8f86fc3e (patch)
tree157d627863d76a4c256a27cae27ce2e8566c7ea0 /test-chill/unit-tests/test__extract.py
parente87b55ad69f0ac6211daae741b32c8ee9dcbe470 (diff)
parent8c646f24570079eac53e58fcf42d0d4fbc437ee3 (diff)
downloadchill-8d73c8fcc75556c1df71dd39dd99783f8f86fc3e.tar.gz
chill-8d73c8fcc75556c1df71dd39dd99783f8f86fc3e.tar.bz2
chill-8d73c8fcc75556c1df71dd39dd99783f8f86fc3e.zip
Merge pull request #2 from dhuth/master
Moved omega into chill.
Diffstat (limited to 'test-chill/unit-tests/test__extract.py')
-rw-r--r--test-chill/unit-tests/test__extract.py48
1 files changed, 48 insertions, 0 deletions
diff --git a/test-chill/unit-tests/test__extract.py b/test-chill/unit-tests/test__extract.py
new file mode 100644
index 0000000..72cba8a
--- /dev/null
+++ b/test-chill/unit-tests/test__extract.py
@@ -0,0 +1,48 @@
+import ast
+import unittest
+
+import testchill._extract as _extract
+import testchill.util as util
+
+class TestExtraction(unittest.TestCase):
+ def setUp(self):
+ self._TagExtractor_parse_test_data = [
+ (('a',''), []),
+ (('a','x<a>yy</a>z'), [('yy', {})]),
+ (('a','x<a>yy</a>z<a>ww</a>g'), [('yy', {}), ('ww',{})]),
+ (('a','x<a>yy</a>z<b>ww</b>g'), [('yy', {})])
+ ]
+ self._commented_test_data = [
+ (('no comment here','cc'), []),
+ (('one comment //xxx\n','cc'), ['xxx']),
+ (('two comments //xxx\nunrelated//yyy\n', 'cc'), ['xxx','yyy']),
+ (('two comments //xxx\nunrelated//yyy', 'cc'), ['xxx','yyy']),
+ (('ss/*x\ny\n*/z','cc'),['x\ny\n']),
+ (('ss/*x\ny\n*/z//q\nc','cc'),['x\ny\n','q']),
+ (('ss###x#\n','py'),['x#']),
+ (('ss"""x"""\n','py'),['x'])
+ ]
+
+ def test__commented(self):
+ def run(txt, ext):
+ return list(_extract._TagExtractor._commented(txt, ext))
+ for args, res in self._commented_test_data:
+ self.assertEqual(run(*args), res)
+
+ #def test_extract(self):
+ # def testfunc(tag, txt):
+ # temp = util.mktemp()
+ # with open(temp, 'w') as f:
+ # f.write(txt)
+ # extracted = _extract._TagExtractor.extract_tag(tag, temp)
+ # util.rmtemp()
+ # return extracted
+ #
+ # for args, res in self.test_extract_data:
+ # self.assertEqual(testfunc(*args), res)
+
+ def test__TagExtractor_parse(self):
+ def testfunc(tag, txt):
+ return _extract._TagExtractor._parse(tag, txt)
+ for args, exp in self._TagExtractor_parse_test_data:
+ self.assertEqual(testfunc(*args), exp)