44import json
55from dataclasses import dataclass , field
66from typing import TYPE_CHECKING , Any , Callable , Generator
7+ from venv import logger
78
89from .. import GenerationConfig
910from ..constants import NOT_SET
@@ -32,6 +33,7 @@ class ParsedData:
3233 """
3334
3435 original_case : Case
36+ prev_case_id : str | None
3537 parameters : dict [str , Any ]
3638 body : Any = NOT_SET
3739
@@ -92,12 +94,17 @@ class Feedback:
9294
9395 def add_test_case (self , case : Case , response : GenericResponse ) -> None :
9496 """Store test data to reuse it in the future additional tests."""
97+ logger .debug ("deps/schemathesis/src/schemathesis/stateful/__init__.py Storing feedback for %r" , case )
9598 for stateful_test in case .operation .get_stateful_tests (response , self .stateful ):
99+ logger .debug ("deps/schemathesis/src/schemathesis/stateful/__init__.py Adding stateful test %r" , stateful_test )
96100 data = self .stateful_tests .setdefault (
97101 stateful_test .name , StatefulData (stateful_test )
98102 )
99103 data .store (case , response )
104+ logger .debug ("deps/schemathesis/src/schemathesis/stateful/__init__.py Stored feedback for %r" , case )
100105 self .original_case = case
106+ self .original_case .case_id = case .case_id
107+ logger .debug ("deps/schemathesis/src/schemathesis/stateful/__init__.py Original case %r" , self .original_case .case_id )
101108
102109 def get_stateful_tests (
103110 self ,
@@ -115,13 +122,18 @@ def get_stateful_tests(
115122 from .._hypothesis import create_test
116123
117124 for data in self .stateful_tests .values ():
125+ logger .debug ("deps/schemathesis/src/schemathesis/stateful/__init__.py Data in stateful test lists %r" , data )
118126 # Có thể phát triển thêm ở đây, chọn case như nào để stateful, hay số lượng case để stateful
119127 for parsed_data in data .container :
128+ logger .debug ("deps/schemathesis/src/schemathesis/stateful/__init__.py Parsed data %r" , parsed_data )
120129 stateful_data = StatefulData (
121130 stateful_test = data .stateful_test , container = [parsed_data ]
122131 )
123-
132+ logger . debug ( "deps/schemathesis/src/schemathesis/stateful/__init__.py Stateful data %r" , stateful_data )
124133 operation = stateful_data .make_operation ()
134+ logger .debug ("deps/schemathesis/src/schemathesis/stateful/__init__.py Operation %r" , operation )
135+ logger .debug ("deps/schemathesis/src/schemathesis/stateful/__init__.py Previous testcase %r" , parsed_data .prev_case_id )
136+ self .original_case .case_id = parsed_data .prev_case_id
125137 _as_strategy_kwargs : dict [str , Any ] | None
126138 if callable (as_strategy_kwargs ):
127139 _as_strategy_kwargs = as_strategy_kwargs (operation )
@@ -135,6 +147,7 @@ def get_stateful_tests(
135147 data_generation_methods = operation .schema .data_generation_methods ,
136148 generation_config = generation_config ,
137149 as_strategy_kwargs = _as_strategy_kwargs ,
150+ prev_stateful_case = self .original_case ,
138151 )
139152 yield Ok ((operation , test_function ))
140153
0 commit comments