Skip to content

Commit

Permalink
chore: ExecutionEvent.asdict adds the event_type field which is t…
Browse files Browse the repository at this point in the history
…he event class name
  • Loading branch information
Stranger6667 committed Jun 13, 2021
1 parent 6256be0 commit 6fad51c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
4 changes: 4 additions & 0 deletions docs/changelog.rst
Expand Up @@ -4,6 +4,10 @@ Changelog
`Unreleased`_ - TBD
-------------------

**Changed**

- ``ExecutionEvent.asdict`` adds the ``event_type`` field which is the event class name.

`3.9.0`_ - 2021-06-07
---------------------

Expand Down
1 change: 0 additions & 1 deletion src/schemathesis/cli/debug.py
Expand Up @@ -14,7 +14,6 @@ class DebugOutputHandler(EventHandler):
def handle_event(self, context: ExecutionContext, event: events.ExecutionEvent) -> None:
stream = self.file_handle.open()
data = event.asdict()
data["event_type"] = event.__class__.__name__
stream.write(json.dumps(data))
stream.write("\n")

Expand Down
8 changes: 6 additions & 2 deletions src/schemathesis/runner/events.py
@@ -1,6 +1,6 @@
import threading
import time
from typing import Dict, List, Optional, Union
from typing import Any, Dict, List, Optional, Union

import attr
from requests import exceptions
Expand All @@ -16,7 +16,11 @@
class ExecutionEvent:
"""Generic execution event."""

asdict = attr.asdict
def asdict(self, **kwargs: Any) -> Dict[str, Any]:
data = attr.asdict(self, **kwargs)
# An internal tag for simpler type identification
data["event_type"] = self.__class__.__name__
return data


@attr.s(slots=True) # pragma: no mutate
Expand Down

0 comments on commit 6fad51c

Please sign in to comment.