예제 #1
0
    def test_selector_regex_colon(self):
        p = Parser('/if.*:/ : E101')
        assert list(p._lines()) == [
            (1, '/if.*:/ : E101'),
        ]

        assert list(p._parsed_lines()) == [
            (1, ['/if.*:/'], 'E101'),
        ]
예제 #2
0
    def test_selector_regex_colon(self):
        p = Parser('/if.*:/ : E101')
        assert list(p._lines()) == [
            (1, '/if.*:/ : E101'),
        ]

        assert list(p._parsed_lines()) == [
            (1, ['/if.*:/'], 'E101'),
        ]
예제 #3
0
    def test_selector_regex(self):
        p = Parser('/foo/ : E101')
        assert list(p._lines()) == [
            (1, '/foo/ : E101'),
        ]

        assert list(p._parsed_lines()) == [
            (1, ['/foo/'], 'E101'),
        ]

        assert p._rules == [
            Rule([RegexSelector('foo')], 'E101'),
        ]
예제 #4
0
    def test_selector_explicit_relative_dir(self):
        p = Parser('./ : E101')
        assert list(p._lines()) == [
            (1, './ : E101'),
        ]

        assert list(p._parsed_lines()) == [
            (1, ['./'], 'E101'),
        ]

        assert p._rules == [
            Rule([FileSelector('./')], 'E101'),
        ]
예제 #5
0
    def test_selector_regex_hash(self):
        p = Parser('/# noqa/ : E101')
        assert list(p._lines()) == [
            (1, '/# noqa/ : E101'),
        ]

        assert list(p._parsed_lines()) == [
            (1, ['/# noqa/'], 'E101'),
        ]

        assert p._rules == [
            Rule([RegexSelector('# noqa')], 'E101'),
        ]
예제 #6
0
    def test_selector_filename(self):
        p = Parser('foo.py : E101')
        assert list(p._lines()) == [
            (1, 'foo.py : E101'),
        ]

        assert list(p._parsed_lines()) == [
            (1, ['foo.py'], 'E101'),
        ]

        assert p._rules == [
            Rule([FileSelector('foo.py')], 'E101'),
        ]
예제 #7
0
    def test_selector_filename(self):
        p = Parser('foo.py : E101')
        assert list(p._lines()) == [
            (1, 'foo.py : E101'),
        ]

        assert list(p._parsed_lines()) == [
            (1, ['foo.py'], 'E101'),
        ]

        assert p._rules == [
            Rule([FileSelector('foo.py')], 'E101'),
        ]
예제 #8
0
    def test_selector_regex_multi(self):
        p = Parser('/(a, b)/ , /(c, d)/ : E101')
        assert list(p._lines()) == [
            (1, '/(a, b)/ , /(c, d)/ : E101'),
        ]

        assert list(p._parsed_lines()) == [
            (1, ['/(a, b)/', '/(c, d)/'], 'E101'),
        ]

        assert p._rules == [
            Rule([RegexSelector('(a, b)'), RegexSelector('(c, d)')], 'E101'),
        ]
예제 #9
0
    def test_selector_filename_explicit_relative(self):
        p = Parser('./foo.py : E101')
        assert list(p._lines()) == [
            (1, './foo.py : E101'),
        ]

        assert list(p._parsed_lines()) == [
            (1, ['./foo.py'], 'E101'),
        ]

        assert p._rules == [
            Rule([FileSelector('./foo.py')], 'E101'),
        ]
예제 #10
0
    def test_selector_explicit_relative_dir(self):
        p = Parser('./ : E101')
        assert list(p._lines()) == [
            (1, './ : E101'),
        ]

        assert list(p._parsed_lines()) == [
            (1, ['./'], 'E101'),
        ]

        assert p._rules == [
            Rule([FileSelector('./')], 'E101'),
        ]
예제 #11
0
    def test_selector_filename_explicit_relative(self):
        p = Parser('./foo.py : E101')
        assert list(p._lines()) == [
            (1, './foo.py : E101'),
        ]

        assert list(p._parsed_lines()) == [
            (1, ['./foo.py'], 'E101'),
        ]

        assert p._rules == [
            Rule([FileSelector('./foo.py')], 'E101'),
        ]
예제 #12
0
    def test_selector_dir(self):
        p = Parser('tests/ : E101')
        assert list(p._lines()) == [
            (1, 'tests/ : E101'),
        ]

        assert list(p._parsed_lines()) == [
            (1, ['tests/'], 'E101'),
        ]

        assert p._rules == [
            Rule([FileSelector('tests/')], 'E101'),
        ]
예제 #13
0
    def test_selector_code_multi(self):
        p = Parser('E100, E200 : E101')
        assert list(p._lines()) == [
            (1, 'E100, E200 : E101'),
        ]

        assert list(p._parsed_lines()) == [
            (1, ['E100', 'E200'], 'E101'),
        ]

        assert p._rules == [
            Rule([CodeSelector('E100'), CodeSelector('E200')], 'E101'),
        ]
예제 #14
0
    def test_selector_regex_hash(self):
        p = Parser('/# noqa/ : E101')
        assert list(p._lines()) == [
            (1, '/# noqa/ : E101'),
        ]

        assert list(p._parsed_lines()) == [
            (1, ['/# noqa/'], 'E101'),
        ]

        assert p._rules == [
            Rule([RegexSelector('# noqa')], 'E101'),
        ]
예제 #15
0
    def test_selector_comment_suffix(self):
        p = Parser('E100 : E101 # foo')
        assert list(p._lines()) == [
            (1, 'E100 : E101 # foo'),
        ]

        assert list(p._parsed_lines()) == [
            (1, ['E100'], 'E101'),
        ]

        assert p._rules == [
            Rule([CodeSelector('E100')], 'E101'),
        ]
예제 #16
0
    def test_selector_regex_comma(self):
        p = Parser('/(a, b)/ : E101')
        assert list(p._lines()) == [
            (1, '/(a, b)/ : E101'),
        ]

        assert list(p._parsed_lines()) == [
            (1, ['/(a, b)/'], 'E101'),
        ]

        assert p._rules == [
            Rule([RegexSelector('(a, b)')], 'E101'),
        ]
예제 #17
0
    def test_selector_code(self):
        p = Parser('E100 : E101')
        assert list(p._lines()) == [
            (1, 'E100 : E101'),
        ]

        assert list(p._parsed_lines()) == [
            (1, ['E100'], 'E101'),
        ]

        assert p._rules == [
            Rule([CodeSelector('E100')], 'E101'),
        ]
예제 #18
0
    def test_selector_regex(self):
        p = Parser('/foo/ : E101')
        assert list(p._lines()) == [
            (1, '/foo/ : E101'),
        ]

        assert list(p._parsed_lines()) == [
            (1, ['/foo/'], 'E101'),
        ]

        assert p._rules == [
            Rule([RegexSelector('foo')], 'E101'),
        ]
예제 #19
0
    def test_selector_dir(self):
        p = Parser('tests/ : E101')
        assert list(p._lines()) == [
            (1, 'tests/ : E101'),
        ]

        assert list(p._parsed_lines()) == [
            (1, ['tests/'], 'E101'),
        ]

        assert p._rules == [
            Rule([FileSelector('tests/')], 'E101'),
        ]
예제 #20
0
    def test_selector_explicit_relative_star(self):
        p = Parser('./* : E101')
        assert list(p._lines()) == [
            (1, './* : E101'),
        ]

        assert list(p._parsed_lines()) == [
            (1, ['./*'], 'E101'),
        ]

        # TODO(#9): This should be a FileSelector, not a CodeSelector
        assert p._rules == [
            Rule([CodeSelector('./*')], 'E101'),
        ]
예제 #21
0
    def test_selector_explicit_relative_star(self):
        p = Parser('./* : E101')
        assert list(p._lines()) == [
            (1, './* : E101'),
        ]

        assert list(p._parsed_lines()) == [
            (1, ['./*'], 'E101'),
        ]

        # TODO(#9): This should be a FileSelector, not a CodeSelector
        assert p._rules == [
            Rule([CodeSelector('./*')], 'E101'),
        ]
예제 #22
0
    def test_selector_star(self):
        p = Parser('* : E101')
        assert list(p._lines()) == [
            (1, '* : E101'),
        ]

        assert list(p._parsed_lines()) == [
            (1, ['*'], 'E101'),
        ]

        # TODO(#9): This is a CodeSelector, which isnt suitable,
        # but a good purpose for this has not been established.
        assert p._rules == [
            Rule([CodeSelector('*')], 'E101'),
        ]
예제 #23
0
    def test_selector_star(self):
        p = Parser('* : E101')
        assert list(p._lines()) == [
            (1, '* : E101'),
        ]

        assert list(p._parsed_lines()) == [
            (1, ['*'], 'E101'),
        ]

        # TODO(#9): This is a CodeSelector, which isnt suitable,
        # but a good purpose for this has not been established.
        assert p._rules == [
            Rule([CodeSelector('*')], 'E101'),
        ]
예제 #24
0
    def test_selector_marker(self):
        p = Parser("python_version == '2.4' : E101")
        assert list(p._lines()) == [
            (1, "python_version == '2.4' : E101"),
        ]

        assert list(p._parsed_lines()) == [
            (1, ["python_version == '2.4'"], 'E101'),
        ]

        assert p._rules == [
            Rule(
                [EnvironmentMarkerSelector("python_version == '2.4'")],
                'E101',
            ),
        ]
예제 #25
0
    def test_selector_marker(self):
        p = Parser("python_version == '2.4' : E101")
        assert list(p._lines()) == [
            (1, "python_version == '2.4' : E101"),
        ]

        assert list(p._parsed_lines()) == [
            (1, ["python_version == '2.4'"], 'E101'),
        ]

        assert p._rules == [
            Rule(
                [EnvironmentMarkerSelector("python_version == '2.4'")],
                'E101',
            ),
        ]
예제 #26
0
    def test_selector_regex_codes_append(self):
        p = Parser('/# !qa: *(?P<codes>[A-Z0-9, ]*)/ : +(?P<codes>)')

        assert list(p._lines()) == [
            (1, '/# !qa: *(?P<codes>[A-Z0-9, ]*)/ : +(?P<codes>)'),
        ]

        assert list(p._parsed_lines()) == [
            (1, ['/# !qa: *(?P<codes>[A-Z0-9, ]*)/'], '+(?P<codes>)'),
        ]

        assert p._rules == [
            Rule(
                [RegexSelector('# !qa: *(?P<codes>[A-Z0-9, ]*)')],
                '(?P<codes>)',
            ),
        ]
예제 #27
0
    def test_selector_regex_codes_append(self):
        p = Parser('/# !qa: *(?P<codes>[A-Z0-9, ]*)/ : +(?P<codes>)')

        assert list(p._lines()) == [
            (1, '/# !qa: *(?P<codes>[A-Z0-9, ]*)/ : +(?P<codes>)'),
        ]

        assert list(p._parsed_lines()) == [
            (1, ['/# !qa: *(?P<codes>[A-Z0-9, ]*)/'], '+(?P<codes>)'),
        ]

        assert p._rules == [
            Rule(
                [RegexSelector('# !qa: *(?P<codes>[A-Z0-9, ]*)')],
                '(?P<codes>)',
            ),
        ]
예제 #28
0
 def test_selector_comment_empty_line(self):
     p = Parser('# foo')
     assert list(p._lines()) == []
예제 #29
0
 def test_selector_comment_empty_line(self):
     p = Parser('# foo')
     assert list(p._lines()) == []