示例#1
0
    def test_tabwidth_8(self):
        #        (line, (raw, effective))
        tests = (
            ('no spaces', (0, 0)),
            # Internal space isn't counted.
            ('        space test', (8, 8)),
            ('\ttab test', (1, 8)),
            ('\t\tdouble tabs test', (2, 16)),
            # Different results when mixing tabs and spaces.
            ('        \tmixed test', (9, 16)),
            ('      \t  mixed test', (9, 10)),
            ('\t        mixed test', (9, 16)),
            # Spaces not divisible by tabwidth.
            ('  \tmixed test', (3, 8)),
            (' \t mixed test', (3, 9)),
            ('\t  mixed test', (3, 10)),
            # Only checks spaces and tabs.
            ('\nnewline test', (0, 0)))

        for line, expected in tests:
            with self.subTest(line=line):
                self.assertEqual(
                    editor.get_line_indent(line, tabwidth=8),
                    expected,
                )
 def test_empty_lines(self):
     for tabwidth in [1, 2, 4, 6, 8]:
         for line in ['', '\n']:
             with self.subTest(line=line, tabwidth=tabwidth):
                 self.assertEqual(
                     editor.get_line_indent(line, tabwidth=tabwidth),
                     (0, 0),
                 )