| Line | |
|---|
| 1 | # -*- coding: utf-8 -*- |
|---|
| 2 | # |
|---|
| 3 | # Copyright (C) 2011 Odd Simon Simonsen <oddsimons@gmail.com> |
|---|
| 4 | # |
|---|
| 5 | # This software is licensed as described in the file COPYING, which |
|---|
| 6 | # you should have received as part of this distribution. |
|---|
| 7 | # |
|---|
| 8 | |
|---|
| 9 | import doctest |
|---|
| 10 | import unittest |
|---|
| 11 | |
|---|
| 12 | import tractags.query |
|---|
| 13 | |
|---|
| 14 | |
|---|
| 15 | class QueryTestCase(unittest.TestCase): |
|---|
| 16 | def test_parse(self): |
|---|
| 17 | """Verify tokenization of quoted strings and strings with unary quotes. |
|---|
| 18 | |
|---|
| 19 | This as been reported as th:ticket:9057. |
|---|
| 20 | """ |
|---|
| 21 | singlequote_phrase = r"""alpha'beta"gamma or 'alpha\'beta"gamma'""" |
|---|
| 22 | q = tractags.query.Query |
|---|
| 23 | self.assertEquals("""\ |
|---|
| 24 | (or |
|---|
| 25 | ("alpha'beta\"gamma") |
|---|
| 26 | ("alpha'beta\"gamma"))""", repr(q(singlequote_phrase))) |
|---|
| 27 | |
|---|
| 28 | doublequote_phrase = r'alpha or "beta\'gamma\"delta" or ""' |
|---|
| 29 | self.assertEquals("""\ |
|---|
| 30 | (or |
|---|
| 31 | ("alpha") |
|---|
| 32 | (or |
|---|
| 33 | ("beta'gamma"delta") |
|---|
| 34 | ("")))""", repr(q(doublequote_phrase))) |
|---|
| 35 | |
|---|
| 36 | |
|---|
| 37 | def test_suite(): |
|---|
| 38 | suite = unittest.TestSuite() |
|---|
| 39 | suite.addTest(doctest.DocTestSuite(module=tractags.query)) |
|---|
| 40 | suite.addTest(unittest.makeSuite(QueryTestCase)) |
|---|
| 41 | return suite |
|---|
| 42 | |
|---|
| 43 | |
|---|
| 44 | if __name__ == '__main__': |
|---|
| 45 | unittest.main(defaultTest='test_suite') |
|---|
Note: See
TracBrowser
for help on using the repository browser.