Ejemplo n.º 1
0
 def test_single_quote_fail(self, AddMessageMock):
     s = cStringIO.StringIO("def function_called('some string', 23):")
     tokens = tokenize.generate_tokens(s.readline)
     linter = pylint.lint.PyLinter()
     checker = QuotationStyleChecker(linter)
     checker.process_tokens(tokens)
     AddMessageMock.assert_called_with("C9801", 1, None, None)
Ejemplo n.º 2
0
 def test_single_quote_fail(self, AddMessageMock):
     s = cStringIO.StringIO("def function_called('some string', 23):")
     tokens = tokenize.generate_tokens(s.readline)
     linter = pylint.lint.PyLinter()
     checker = QuotationStyleChecker(linter)
     checker.process_tokens(tokens)
     AddMessageMock.assert_called_with("C9801", 1, None, None)
Ejemplo n.º 3
0
    def test_single_quote_wrap_double_pass(self, AddMessageMock):
        s = cStringIO.StringIO("""
def function_called('some "inner" string', 23):
""")
        tokens = tokenize.generate_tokens(s.readline)
        linter = pylint.lint.PyLinter()
        checker = QuotationStyleChecker(linter)
        checker.process_tokens(tokens)
        self.assertEquals(AddMessageMock.call_count, 0)
Ejemplo n.º 4
0
    def test_single_quote_wrap_double_pass(self, AddMessageMock):
        s = cStringIO.StringIO("""
def function_called('some "inner" string', 23):
""")
        tokens = tokenize.generate_tokens(s.readline)
        linter = pylint.lint.PyLinter()
        checker = QuotationStyleChecker(linter)
        checker.process_tokens(tokens)
        self.assertEquals(AddMessageMock.call_count, 0)
Ejemplo n.º 5
0
    def test_single_quote_multiple_tokens_fail(self, AddMessageMock):
        s = cStringIO.StringIO("""
def function_called("some string", 23):
    x = 1
    s = 'This is an invalid string'
    y = 500
    return 'Invalid'
""")
        tokens = tokenize.generate_tokens(s.readline)
        linter = pylint.lint.PyLinter()
        checker = QuotationStyleChecker(linter)
        checker.process_tokens(tokens)
        self.assertEquals(AddMessageMock.call_count, 2)
Ejemplo n.º 6
0
    def test_single_quote_multiline_fail(self, AddMessageMock):
        s = cStringIO.StringIO("""
def function_called("some string", 23):
    x = 1
    s = 'This is a valid "entry"'
    y = 500
    return 'Invalid'
""")
        tokens = tokenize.generate_tokens(s.readline)
        linter = pylint.lint.PyLinter()
        checker = QuotationStyleChecker(linter)
        checker.process_tokens(tokens)
        AddMessageMock.assert_called_with("C9801", 6, None, None)
Ejemplo n.º 7
0
    def test_single_quote_multiple_tokens_fail(self, AddMessageMock):
        s = cStringIO.StringIO("""
def function_called("some string", 23):
    x = 1
    s = 'This is an invalid string'
    y = 500
    return 'Invalid'
""")
        tokens = tokenize.generate_tokens(s.readline)
        linter = pylint.lint.PyLinter()
        checker = QuotationStyleChecker(linter)
        checker.process_tokens(tokens)
        self.assertEquals(AddMessageMock.call_count, 2)
Ejemplo n.º 8
0
    def test_single_quote_multiline_fail(self, AddMessageMock):
        s = cStringIO.StringIO("""
def function_called("some string", 23):
    x = 1
    s = 'This is a valid "entry"'
    y = 500
    return 'Invalid'
""")
        tokens = tokenize.generate_tokens(s.readline)
        linter = pylint.lint.PyLinter()
        checker = QuotationStyleChecker(linter)
        checker.process_tokens(tokens)
        AddMessageMock.assert_called_with("C9801", 6, None, None)