diff options
author | Derick Huth <derickhuth@gmail.com> | 2016-02-10 11:13:08 -0700 |
---|---|---|
committer | Derick Huth <derickhuth@gmail.com> | 2016-02-10 11:13:08 -0700 |
commit | 1dd03ee01bff2a70e758ce984476527f3ff42c68 (patch) | |
tree | 9731867c7019ec9b6ee111c8fa9f92a92119b5ec /test-chill/unit-tests/test__extract.py | |
parent | 4631ad76927d433da5d55c3c373a1dfd0f74c9d4 (diff) | |
parent | d68532f2f3ba332199f84818cb047d69a3f33588 (diff) | |
download | chill-1dd03ee01bff2a70e758ce984476527f3ff42c68.tar.gz chill-1dd03ee01bff2a70e758ce984476527f3ff42c68.tar.bz2 chill-1dd03ee01bff2a70e758ce984476527f3ff42c68.zip |
Merge pull request #8 from dhuth/master
w/ python test suite
Diffstat (limited to 'test-chill/unit-tests/test__extract.py')
-rw-r--r-- | test-chill/unit-tests/test__extract.py | 48 |
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) |