python - problem: how to reference to objects/variables created in decorator from injected method? -
i encountered problem availability of objects created within decorator, , needed in test_case
method. code presenting below:
def execute_results_navigation(test_case): def wrapper(self,*args,**kwargs): result=result() pagination=pagination() results_page_index=1 while results_page_index<=pagination.get_pages_number(): results_object_index in range(results.get_objects_number_per_single_page()): test_case(self,*args,**kwargs) pagination.set_active_page_number(results_page_index) results_page_index+=1 return wrapper
in place of test_case
method "injected" following code (everything takes place using predefined decorator):
@execute_results_navigation def test_check_availability_of_search_results(self): """ test case 2.22 """ offer=offer() result.select_hotel(results_caller["button"],results_object_index) offer_price=offer.get_offer_object_details().price offer.verify_offer_availability(offer_price) offer.back_to_search_results()
test_case
method has no access result
,pagination
objects , results_object_index
variable. objects have been initialized when calling decorator. maybe i'm doing wrong method, thought these instances exist within wrapper
method , access them should not cause problems.
you won't able access local variables defined in wrapper within test_case.
looks test_check_availability_of_search_results instance method, 1 way solve problem assign variables attributes of 'self'.
Comments
Post a Comment