Пример #1
0
 def test_code_ascii_is_not_utf8(self):
     utf8_python = u"a = 'this is utf-8 [\u272a]'"
     checker = PythonChecker('bogus', utf8_python, self.reporter)
     checker.check_text()
     self.assertEqual(
         [(1, 'Non-ascii characer at position 21.')],
         self.reporter.messages)
Пример #2
0
 def test_code_utf8(self):
     utf8_python = u"a = 'this is utf-8 [\u272a]'"
     checker = PythonChecker('bogus', utf8_python, self.reporter)
     checker.encoding = 'utf-8'
     checker.check_text()
Пример #3
0
 def _test_encoding(self, python, expected_encoding='foo-encoding'):
     checker = PythonChecker(
        'bogus', python % dict(encoding=expected_encoding), self.reporter)
     checker.check_text()
     self.assertEqual(expected_encoding, checker.encoding)
Пример #4
0
 def test_code_with_pdb(self):
     pdb_python = "import pdb; pdb." + "set_trace()"
     checker = PythonChecker('bogus', pdb_python, self.reporter)
     checker.check_text()
     self.assertEqual(
         [(1, 'Line contains a call to pdb.')], self.reporter.messages)
Пример #5
0
 def test_code_without_issues(self):
     checker = PythonChecker('bogus', good_python, self.reporter)
     checker.check_text()
     self.assertEqual([], self.reporter.messages)
Пример #6
0
 def create_and_check(self, file_name, text):
     """Used by the TestAnyTextMixin tests."""
     checker = PythonChecker(file_name, text, self.reporter)
     checker.check_text()