blob: b2964f5d950ceb370a53de378ab2a639925f31f6 [file] [log] [blame]
Bill Wendling7d623452015-03-18 13:36:07 -07001# Copyright 2015 Google Inc. All Rights Reserved.
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14"""Tests for yapf.format_token."""
15
16import unittest
17
18from lib2to3 import pytree
19from lib2to3.pgen2 import token
20from yapf.yapflib import format_token
21
22
23class FormatTokenTest(unittest.TestCase):
24
25 def testSimple(self):
26 tok = format_token.FormatToken(pytree.Leaf(token.STRING, "'hello world'"))
27 self.assertEqual("FormatToken(name=STRING, value='hello world')", str(tok))
28 self.assertTrue(tok.is_string)
29
30 tok = format_token.FormatToken(pytree.Leaf(token.COMMENT, "# A comment"))
31 self.assertEqual("FormatToken(name=COMMENT, value=# A comment)", str(tok))
32 self.assertTrue(tok.is_comment)
33
34
Bill Wendling7d623452015-03-18 13:36:07 -070035if __name__ == "__main__":
36 unittest.main()