From f176cea4e33c9557211378c80cb1b6743b48e4d1 Mon Sep 17 00:00:00 2001 From: Christophe Bedard Date: Tue, 31 Dec 2019 19:34:35 -0500 Subject: [PATCH] Move RequiredEventNotFoundError class to Processor class --- .../test/tracetools_analysis/test_processor.py | 3 +-- .../tracetools_analysis/processor/__init__.py | 11 ++++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/tracetools_analysis/test/tracetools_analysis/test_processor.py b/tracetools_analysis/test/tracetools_analysis/test_processor.py index 43b015f..2798f73 100644 --- a/tracetools_analysis/test/tracetools_analysis/test_processor.py +++ b/tracetools_analysis/test/tracetools_analysis/test_processor.py @@ -19,7 +19,6 @@ import unittest from tracetools_analysis.processor import EventHandler from tracetools_analysis.processor import EventMetadata from tracetools_analysis.processor import Processor -from tracetools_analysis.processor import RequiredEventNotFoundError class StubHandler1(EventHandler): @@ -149,7 +148,7 @@ class TestProcessor(unittest.TestCase): 'cpu_id': 0, } # Fails check - with self.assertRaises(RequiredEventNotFoundError): + with self.assertRaises(Processor.RequiredEventNotFoundError): Processor(EventHandlerWithRequiredEvent()).process([mock_event]) required_mock_event = { diff --git a/tracetools_analysis/tracetools_analysis/processor/__init__.py b/tracetools_analysis/tracetools_analysis/processor/__init__.py index 5ae8540..4605132 100644 --- a/tracetools_analysis/tracetools_analysis/processor/__init__.py +++ b/tracetools_analysis/tracetools_analysis/processor/__init__.py @@ -253,13 +253,14 @@ class DependencySolver(): visited.add(dep_type) -class RequiredEventNotFoundError(RuntimeError): - pass - - class Processor(): """Processor class, which dispatches events to event handlers.""" + class RequiredEventNotFoundError(RuntimeError): + """When a trace does not contain one event required by an EventHandler.""" + + pass + def __init__( self, *handlers: EventHandler, @@ -339,7 +340,7 @@ class Processor(): for handler in self._expanded_handlers: for name in handler.required_events(): if name not in event_names: - raise RequiredEventNotFoundError( + raise self.RequiredEventNotFoundError( f'missing event {name} for {handler.__class__.__name__}' )