Move RequiredEventNotFoundError class to Processor class
This commit is contained in:
parent
d0229a0bed
commit
f176cea4e3
2 changed files with 7 additions and 7 deletions
|
@ -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 = {
|
||||
|
|
|
@ -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__}'
|
||||
)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue