コード例 #1
0
ファイル: test.py プロジェクト: johnthagen/flake8-strings
class StringCheckerTestCase(unittest.TestCase):
    def setUp(self):
        file_name = 'tests/S800.py'
        with open(file_name, mode='rt') as file:
            tree = ast.parse(file.read())
            self.checker = StringChecker(tree, file_name)

    def test_single(self):
        self.checker.string_quote = StringQuotes.single
        errors = []
        for error in self.checker.run():
            errors.append(error[:2])

        self.assertEqual(
            errors,
            [(1, 9), (7, 15), (16, 13), (19, 21), (22, 14), (25, 22), (28, 17), (31, 25)])

    def test_double(self):
        self.checker.string_quote = StringQuotes.double
        errors = []
        for error in self.checker.run():
            errors.append(error[:2])

        self.assertEqual(
            errors,
            [(2, 9), (8, 15), (17, 13), (20, 21), (23, 14), (26, 22), (29, 17), (32, 25)])