Skip to content

Commit

Permalink
chore: Store data_generation_method in BeforeExecution
Browse files Browse the repository at this point in the history
  • Loading branch information
Stranger6667 committed Oct 9, 2021
1 parent 78dd617 commit 11471d8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/schemathesis/runner/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,19 +81,24 @@ class BeforeExecution(CurrentOperationMixin, ExecutionEvent):
relative_path: str = attr.ib() # pragma: no mutate
# The current level of recursion during stateful testing
recursion_level: int = attr.ib() # pragma: no mutate
# The way data will be generated
data_generation_method: str = attr.ib() # pragma: no mutate
# An unique ID which connects events that happen during testing of the same API operation
# It may be useful when multiple threads are involved where incoming events are not ordered
correlation_id: str = attr.ib() # pragma: no mutate
thread_id: int = attr.ib(factory=threading.get_ident) # pragma: no mutate

@classmethod
def from_operation(cls, operation: APIOperation, recursion_level: int, correlation_id: str) -> "BeforeExecution":
def from_operation(
cls, operation: APIOperation, recursion_level: int, data_generation_method: str, correlation_id: str
) -> "BeforeExecution":
return cls(
method=operation.method.upper(),
path=operation.full_path,
verbose_name=operation.verbose_name,
relative_path=operation.path,
recursion_level=recursion_level,
data_generation_method=data_generation_method,
correlation_id=correlation_id,
)

Expand Down
6 changes: 5 additions & 1 deletion src/schemathesis/runner/impl/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ def handle_schema_error(
verbose_name=verbose_name,
relative_path=error.path,
recursion_level=recursion_level,
data_generation_method=data_generation_method,
correlation_id=correlation_id,
)
yield events.AfterExecution(
Expand Down Expand Up @@ -244,7 +245,10 @@ def run_test( # pylint: disable=too-many-locals
# To simplify connecting `before` and `after` events in external systems
correlation_id = uuid.uuid4().hex
yield events.BeforeExecution.from_operation(
operation=operation, recursion_level=recursion_level, correlation_id=correlation_id
operation=operation,
recursion_level=recursion_level,
data_generation_method=data_generation_method,
correlation_id=correlation_id,
)
hypothesis_output: List[str] = []
errors: List[Exception] = []
Expand Down

0 comments on commit 11471d8

Please sign in to comment.