@@ -341,18 +341,19 @@ def test_c2c_mode_enabled():
341341
342342
343343@pytest .mark .skipif (helpers .IS_WSL or helpers .IS_WINDOWS , reason = "Persistence mode not supported on WSL or Windows" )
344- def test_persistence_mode_enabled ():
344+ def test_persistence_mode_enabled (subtests ):
345345 for device in system .Device .get_all_devices ():
346- is_enabled = device .is_persistence_mode_enabled
347- assert isinstance (is_enabled , bool )
348- try :
349- device .is_persistence_mode_enabled = False
350- except nvml .NoPermissionError as e :
351- pytest .xfail (f"nvml.NoPermissionError: { e } " )
352- try :
353- assert device .is_persistence_mode_enabled is False
354- finally :
355- device .is_persistence_mode_enabled = is_enabled
346+ with subtests .test (device_index = device .index ):
347+ is_enabled = device .is_persistence_mode_enabled
348+ assert isinstance (is_enabled , bool )
349+ try :
350+ device .is_persistence_mode_enabled = False
351+ except nvml .NoPermissionError as e :
352+ pytest .xfail (f"nvml.NoPermissionError: { e } " )
353+ try :
354+ assert device .is_persistence_mode_enabled is False
355+ finally :
356+ device .is_persistence_mode_enabled = is_enabled
356357
357358
358359def test_field_values ():
@@ -615,63 +616,66 @@ def test_clock_event_reasons():
615616 assert all (isinstance (reason , system .ClocksEventReasons ) for reason in reasons )
616617
617618
618- def test_fan ():
619+ def test_fan (subtests ):
619620 for device in system .Device .get_all_devices ():
620621 # The fan APIs are only supported on discrete devices with fans,
621622 # but when they are not available `device.num_fans` returns 0.
622623 if device .num_fans == 0 :
623- pytest .skip ("Device has no fans to test" )
624+ with subtests .test (device_index = device .index ):
625+ pytest .skip ("Device has no fans to test" )
624626
625627 for fan_idx in range (device .num_fans ):
626- fan_info = device .get_fan (fan_idx )
627- assert isinstance (fan_info , _device .FanInfo )
628+ with subtests .test (device_index = device .index , fan_idx = fan_idx ):
629+ fan_info = device .get_fan (fan_idx )
630+ assert isinstance (fan_info , _device .FanInfo )
628631
629- speed = fan_info .speed
630- assert isinstance (speed , int )
631- assert 0 <= speed <= 200
632- try :
633- fan_info .speed = 50
634- except nvml .NoPermissionError as e :
635- pytest .xfail (f"nvml.NoPermissionError: { e } " )
636- try :
637- fan_info .speed = speed
632+ speed = fan_info .speed
633+ assert isinstance (speed , int )
634+ assert 0 <= speed <= 200
635+ try :
636+ fan_info .speed = 50
637+ except nvml .NoPermissionError as e :
638+ pytest .xfail (f"nvml.NoPermissionError: { e } " )
639+ try :
640+ fan_info .speed = speed
638641
639- speed_rpm = fan_info .speed_rpm
640- assert isinstance (speed_rpm , int )
641- assert speed_rpm >= 0
642+ speed_rpm = fan_info .speed_rpm
643+ assert isinstance (speed_rpm , int )
644+ assert speed_rpm >= 0
642645
643- target_speed = fan_info .target_speed
644- assert isinstance (target_speed , int )
645- assert speed <= target_speed * 2
646+ target_speed = fan_info .target_speed
647+ assert isinstance (target_speed , int )
648+ assert speed <= target_speed * 2
646649
647- min_ , max_ = fan_info .min_max_speed
648- assert isinstance (min_ , int )
649- assert isinstance (max_ , int )
650- assert min_ <= max_
650+ min_ , max_ = fan_info .min_max_speed
651+ assert isinstance (min_ , int )
652+ assert isinstance (max_ , int )
653+ assert min_ <= max_
651654
652- control_policy = fan_info .control_policy
653- assert isinstance (control_policy , system .FanControlPolicy )
654- finally :
655- fan_info .set_default_speed ()
655+ control_policy = fan_info .control_policy
656+ assert isinstance (control_policy , system .FanControlPolicy )
657+ finally :
658+ fan_info .set_default_speed ()
656659
657660
658- def test_cooler ():
661+ def test_cooler (subtests ):
659662 for device in system .Device .get_all_devices ():
660- # The cooler APIs are only supported on discrete devices with fans,
661- # but when they are not available `device.num_fans` returns 0.
662- if device .num_fans == 0 :
663- pytest .skip ("Device has no coolers to test" )
663+ with subtests .test (device_index = device .index ):
664+ # The cooler APIs are only supported on discrete devices with fans,
665+ # but when they are not available `device.num_fans` returns 0.
666+ if device .num_fans == 0 :
667+ pytest .skip ("Device has no coolers to test" )
664668
665- with unsupported_before (device , DeviceArch .MAXWELL ):
666- cooler_info = device .cooler
669+ with unsupported_before (device , DeviceArch .MAXWELL ):
670+ cooler_info = device .cooler
667671
668- assert isinstance (cooler_info , _device .CoolerInfo )
672+ assert isinstance (cooler_info , _device .CoolerInfo )
669673
670- signal_type = cooler_info .signal_type
671- assert isinstance (signal_type , system .CoolerControl )
674+ signal_type = cooler_info .signal_type
675+ assert isinstance (signal_type , system .CoolerControl )
672676
673- target = cooler_info .target
674- assert all (isinstance (t , system .CoolerTarget ) for t in target )
677+ target = cooler_info .target
678+ assert all (isinstance (t , system .CoolerTarget ) for t in target )
675679
676680
677681def test_temperature ():
0 commit comments