コード例 #1
0
ファイル: test_policy.py プロジェクト: noorul/oslo-incubator
    def test_tokenize(self):
        exemplar = ("(( ( ((() And)) or ) (check:%(miss)s) not)) "
                    "'a-string' \"another-string\"")
        expected = [
            ('(', '('),
            ('(', '('),
            ('(', '('),
            ('(', '('),
            ('(', '('),
            ('(', '('),
            (')', ')'),
            ('and', 'And'),
            (')', ')'),
            (')', ')'),
            ('or', 'or'),
            (')', ')'),
            ('(', '('),
            ('check', 'check:%(miss)s'),
            (')', ')'),
            ('not', 'not'),
            (')', ')'),
            (')', ')'),
            ('string', 'a-string'),
            ('string', 'another-string'),
        ]

        result = list(policy._parse_tokenize(exemplar))

        self.assertEqual(result, expected)
コード例 #2
0
    def test_tokenize(self):
        exemplar = ("(( ( ((() And)) or ) (check:%(miss)s) not)) "
                    "'a-string' \"another-string\"")
        expected = [
            ('(', '('), ('(', '('), ('(', '('), ('(', '('), ('(', '('),
            ('(', '('), (')', ')'), ('and', 'And'),
            (')', ')'), (')', ')'), ('or', 'or'), (')', ')'), ('(', '('),
            ('check', 'check:%(miss)s'), (')', ')'), ('not', 'not'),
            (')', ')'), (')', ')'),
            ('string', 'a-string'),
            ('string', 'another-string'),
        ]

        result = list(policy._parse_tokenize(exemplar))

        self.assertEqual(result, expected)