Ejemplo n.º 1
0
    def test_H104_regex(self):
        """Verify that the H104 regex matches correct lines."""
        self.assertTrue(comments.hacking_has_only_comments(
            None,
            None,
            ['# foo',
             '# bar'],
            1))
        self.assertTrue(comments.hacking_has_only_comments(
            None,
            None,
            ['# foo',
             '# bar',
             ''],
            1))
        self.assertTrue(comments.hacking_has_only_comments(
            None,
            None,
            ['# foo',
             '   ',
             '# bar'],
            1))

        self.assertIsNone(comments.hacking_has_only_comments(
            None,
            None,
            ['# foo',
             '   ',
             '"""foobar"""'],
            1))
        self.assertIsNone(comments.hacking_has_only_comments(
            None,
            None,
            ['# foo',
             '',
             'print(42)'],
            1))
        self.assertIsNone(comments.hacking_has_only_comments(
            None,
            None,
            ['# foo'],
            100))