def test_long_length_good(self):
     long_line = '1234 56189' * 7 + '12345678' + '\n'
     self.file.write(long_line)
     self.file.flush()
     checker = PythonChecker(self.file.name, long_line, self.reporter)
     checker.check_pep8()
     self.assertEqual([], self.reporter.messages)
 def test_code_with_comments(self):
     self.file.write(ugly_style_lines_python)
     self.file.flush()
     checker = PythonChecker(
         self.file.name, ugly_style_lines_python, self.reporter)
     checker.check_pep8()
     self.assertEqual([], self.reporter.messages)
 def test_code_without_issues(self):
     self.file.write(good_python)
     self.file.flush()
     checker = PythonChecker(
         self.file.name, good_python, self.reporter)
     checker.check_pep8()
     self.assertEqual([], self.reporter.messages)
 def test_long_length_bad(self):
     long_line = '1234 56189' * 8 + '\n'
     self.file.write(long_line)
     self.file.flush()
     checker = PythonChecker(self.file.name, long_line, self.reporter)
     checker.check_pep8()
     self.assertEqual(
         [(1, 'E501 line too long (80 characters)')],
         self.reporter.messages)
 def test_code_with_issues(self):
     self.file.write(ugly_style_python)
     self.file.flush()
     checker = PythonChecker(
         self.file.name, ugly_style_python, self.reporter)
     checker.check_pep8()
     self.assertEqual(
         [(4, 'E222 multiple spaces after operator')],
         self.reporter.messages)
 def test_code_with_IndentationError(self):
     self.file.write(bad_indentation_python)
     self.file.flush()
     checker = PythonChecker(
         self.file.name, bad_indentation_python, self.reporter)
     checker.check_pep8()
     expected = [(
         4, 'unindent does not match any outer indentation level: b = 1')]
     self.assertEqual(expected, self.reporter.messages)
 def test_bad_syntax(self):
     self.file.write(bad_syntax2_python)
     self.file.flush()
     checker = PythonChecker(
         self.file.name, ugly_style_python, self.reporter)
     checker.check_pep8()
     self.assertEqual(
         [(4, 'EOF in multi-line statement')],
         self.reporter.messages)
 def test_long_length_options(self):
     long_line = '1234 56189' * 7 + '\n'
     parser = get_option_parser()
     (options, sources) = parser.parse_args(['-m', '60'])
     self.file.write(long_line)
     self.file.flush()
     checker = PythonChecker(
         self.file.name, long_line, self.reporter, options)
     checker.check_pep8()
     self.assertEqual(
         [(1, 'E501 line too long (70 characters)')],
         self.reporter.messages)