def test_is_reportable(self): """Test is_reportable().""" filter_configuration = FilterConfiguration(base_rules=["-xyz"]) options = ProcessorOptions(filter_configuration=filter_configuration, verbosity=3) # Test verbosity self.assertTrue(options.is_reportable("abc", 3, "foo.h")) self.assertFalse(options.is_reportable("abc", 2, "foo.h")) # Test filter self.assertTrue(options.is_reportable("xy", 3, "foo.h")) self.assertFalse(options.is_reportable("xyz", 3, "foo.h"))
def test_call(self): patch_files = parse_patch(self._patch_string) diff = patch_files[self._file_path] options = ProcessorOptions(verbosity=3) handle_error = PatchStyleErrorHandler(diff, self._file_path, options, self._mock_increment_error_count, self._mock_stderr_write) category = "whitespace/tab" confidence = 5 message = "message" # Confirm error is reportable. self.assertTrue(options.is_reportable(category, confidence, self._file_path)) # Confirm error count initialized to zero. self.assertEquals(0, self._error_count) # Test error in unmodified line (error count does not increment). handle_error(1, category, confidence, message) self.assertEquals(0, self._error_count) # Test error in modified line (error count increments). handle_error(2, category, confidence, message) self.assertEquals(1, self._error_count)
def test_call(self): patch_files = parse_patch(self._patch_string) diff = patch_files[self._file_path] options = ProcessorOptions(verbosity=3) handle_error = PatchStyleErrorHandler(diff, self._file_path, options, self._mock_increment_error_count, self._mock_stderr_write) category = "whitespace/tab" confidence = 5 message = "message" # Confirm error is reportable. self.assertTrue( options.is_reportable(category, confidence, self._file_path)) # Confirm error count initialized to zero. self.assertEquals(0, self._error_count) # Test error in unmodified line (error count does not increment). handle_error(1, category, confidence, message) self.assertEquals(0, self._error_count) # Test error in modified line (error count increments). handle_error(2, category, confidence, message) self.assertEquals(1, self._error_count)
def test_call_non_reportable(self): """Test __call__() method with a non-reportable error.""" confidence = 1 options = ProcessorOptions(verbosity=3) self._check_initialized() # Confirm the error is not reportable. self.assertFalse(options.is_reportable(self._category, confidence, self._file_path)) self._call_error_handler(options, confidence) self.assertEquals(0, self._error_count) self.assertEquals("", self._error_messages)
def test_call_non_reportable(self): """Test __call__() method with a non-reportable error.""" confidence = 1 options = ProcessorOptions(verbosity=3) self._check_initialized() # Confirm the error is not reportable. self.assertFalse( options.is_reportable(self._category, confidence, self._file_path)) self._call_error_handler(options, confidence) self.assertEquals(0, self._error_count) self.assertEquals("", self._error_messages)