@@ -2460,12 +2460,8 @@ def finish(self):
2460
2460
# the cached fixture value
2461
2461
if hasattr (self , "cached_result" ):
2462
2462
if self ._fixturemanager .config .option .setuponly :
2463
- tw = self ._fixturemanager .config .get_terminal_writer ()
2464
- tw .line ()
2465
- tw .write (' ' * 2 * self .scopenum )
2466
- tw .write ('TEARDOWN {} {}' .format (self .scope [0 ].upper (), self .argname ))
2463
+ self ._log_fixture_stack ('TEARDOWN' )
2467
2464
if hasattr (self , "cached_param" ):
2468
- tw .write ('[{}]' .format (self .cached_param ))
2469
2465
del self .cached_param
2470
2466
del self .cached_result
2471
2467
@@ -2512,19 +2508,33 @@ def execute(self, request):
2512
2508
2513
2509
try :
2514
2510
result = call_fixture_func (fixturefunc , request , kwargs )
2515
- tw = request .config .get_terminal_writer ()
2516
- tw .line ()
2517
- tw .write (' ' * 2 * self .scopenum )
2518
- tw .write ('SETUP {} {}' .format (self .scope [0 ].upper (), fixturefunc .__name__ ))
2519
- if hasattr (request , 'param' ):
2520
- tw .write ('[{}]' .format (request .param ))
2521
- self .cached_param = request .param
2511
+ # We want to access the params of ids if they exist also in during
2512
+ # the finish() method.
2513
+ if self ._fixturemanager .config .option .setuponly :
2514
+ if hasattr (request , 'param' ):
2515
+ if self .ids :
2516
+ ind = self .params .index (request .param )
2517
+ self .cached_param = self .ids [ind ]
2518
+ else :
2519
+ self .cached_param = request .param
2520
+ self ._log_fixture_stack ('SETUP' )
2522
2521
except Exception :
2523
2522
self .cached_result = (None , my_cache_key , sys .exc_info ())
2524
2523
raise
2525
2524
self .cached_result = (result , my_cache_key , None )
2526
2525
return result
2527
2526
2527
+ def _log_fixture_stack (self , what ):
2528
+ tw = self ._fixturemanager .config .get_terminal_writer ()
2529
+ tw .line ()
2530
+ tw .write (' ' * 2 * self .scopenum )
2531
+ tw .write ('{step} {scope} {fixture}' .format (
2532
+ step = what .ljust (8 ), # align the output to TEARDOWN
2533
+ scope = self .scope [0 ].upper (),
2534
+ fixture = self .argname ))
2535
+ if hasattr (self , 'cached_param' ):
2536
+ tw .write ('[{}]' .format (self .cached_param ))
2537
+
2528
2538
def __repr__ (self ):
2529
2539
return ("<FixtureDef name=%r scope=%r baseid=%r >" %
2530
2540
(self .argname , self .scope , self .baseid ))
0 commit comments