Exemplo n.º 1
0
    def assertNoError(self, lines):
        """Asserts that the specified lines has no errors."""
        self.had_error = False

        def error_for_test(line_number, category, confidence, message):
            """Records if an error occurs."""
            self.had_error = True

        checker = JSChecker('', error_for_test)
        checker.check(lines)
        self.assertFalse(self.had_error, '%s should not have any errors.' % lines)
Exemplo n.º 2
0
    def assertError(self, lines, expected_line_number):
        """Asserts that the specified lines has an error."""
        self.had_error = False

        def error_for_test(line_number, category, confidence, message):
            """Checks if the expected error occurs."""
            self.assertEqual(expected_line_number, line_number)
            self.assertTrue(category in ['whitespace/tab', 'js/syntax'])
            self.had_error = True

        checker = JSChecker('', error_for_test)
        checker.check(lines)
        self.assertTrue(self.had_error, '%s should have an error [whitespace/tab] or [js/syntax].' % lines)