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)
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)
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)
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)