Ejemplo n.º 1
0
    def test_line_indent_does_not_match_block(self, AddMessageMock):
        s = cStringIO.StringIO("""
def some_func():
    x = 100

    y = x * 100
    return y**2
""")
        tokens = tokenize.generate_tokens(s.readline)
        linter = pylint.lint.PyLinter()
        checker = IndentationStyleChecker(linter)
        checker.process_tokens(tokens)
        AddMessageMock.assert_called_with("C9901", 4, None, (4, 0))
Ejemplo n.º 2
0
    def test_line_indent_success(self, AddMessageMock):
        s = cStringIO.StringIO("""
def some_func():
    x = 100
    
    if True:
        y = x * 100
    else:
        y = 2
    
    return y**2
""")
        tokens = tokenize.generate_tokens(s.readline)
        linter = pylint.lint.PyLinter()
        checker = IndentationStyleChecker(linter)
        checker.process_tokens(tokens)
        self.assertEquals(AddMessageMock.call_count, 0)
Ejemplo n.º 3
0
    def test_line_overindented(self, AddMessageMock):
        s = cStringIO.StringIO("""
def some_func():
    x = 100
    
    if True:
            
        y = x * 100
    else:
        y = 2
    return y**2
""")
        tokens = tokenize.generate_tokens(s.readline)
        linter = pylint.lint.PyLinter()
        checker = IndentationStyleChecker(linter)
        checker.process_tokens(tokens)
        AddMessageMock.assert_called_with("C9901", 6, None, (8, 12))