diff --git a/fitparse/processors.py b/fitparse/processors.py index 34b36ba..7948ee3 100644 --- a/fitparse/processors.py +++ b/fitparse/processors.py @@ -59,9 +59,10 @@ def run_message_processor(self, data_message): def _run_processor(self, processor_name, data): try: - getattr(self, processor_name)(data) + processor = getattr(self, processor_name) except AttributeError: - pass + return + processor(data) def process_type_bool(self, field_data): if field_data.value is not None: diff --git a/tests/test_processors.py b/tests/test_processors.py new file mode 100644 index 0000000..a67aad4 --- /dev/null +++ b/tests/test_processors.py @@ -0,0 +1,17 @@ +import unittest + +from fitparse.processors import FitFileDataProcessor + + +class ProcessorErrorHandlingTestCase(unittest.TestCase): + def test_processor_attribute_error_is_not_silently_ignored(self): + class RaisingProcessor(FitFileDataProcessor): + def process_field_test(self, field_data): + raise AttributeError("processor failure") + + with self.assertRaisesRegex(AttributeError, "processor failure"): + RaisingProcessor()._run_processor("process_field_test", object()) + + +if __name__ == "__main__": + unittest.main()