-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun_tests.py
37 lines (28 loc) · 965 Bytes
/
run_tests.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# -*- coding: utf-8 -*-
import ast
import unittest
from flake8_i18n import Flake8i18n
class TestFlake8i18n(unittest.TestCase):
def test_fstring(self):
tree = ast.parse("_(f'')")
checker = Flake8i18n(tree)
ret = list(checker.run())
self.assertEqual(len(ret), 1)
self.assertEqual(ret[0][0], 1)
self.assertEqual(ret[0][1], 0)
def test_format_interp(self):
tree = ast.parse("_('{}'.format('line'))")
checker = Flake8i18n(tree)
ret = list(checker.run())
self.assertEqual(len(ret), 1)
self.assertEqual(ret[0][0], 1)
self.assertEqual(ret[0][1], 0)
def test_printf_interp(self):
tree = ast.parse("_('%s' % 'line')")
checker = Flake8i18n(tree)
ret = list(checker.run())
self.assertEqual(len(ret), 1)
self.assertEqual(ret[0][0], 1)
self.assertEqual(ret[0][1], 0)
if __name__ == '__main__':
unittest.main()