source: tagsplugin/trunk/tractags/tests/query.py

Last change on this file was 16943, checked in by Ryan J Ollos, 6 years ago

TracTags 0.10dev: Make compatible with Trac 1.3.3dev

Fixes #13316.

File size: 1.1 KB
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
9import doctest
10import unittest
11
12import tractags.query
13
14
15class 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
37def 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
44if __name__ == '__main__':
45    unittest.main(defaultTest='test_suite')
Note: See TracBrowser for help on using the repository browser.