File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1313from tests .conftest import make_blinkstick
1414
1515
16+ def get_blinkstick_methods ():
17+ """Get all public methods from BlinkStick class."""
18+ return [
19+ method
20+ for method in dir (BlinkStick )
21+ if callable (getattr (BlinkStick , method )) and not method .startswith ("__" )
22+ ]
23+
24+
1625def test_instantiate ():
1726 """Test that we can instantiate a BlinkStick object."""
1827 bs = BlinkStick ()
1928 assert bs is not None
2029
2130
22- def test_all_methods_require_backend ():
31+ @pytest .mark .parametrize ("method_name" , get_blinkstick_methods ())
32+ def test_all_methods_require_backend (method_name ):
2333 """Test that all methods require a backend."""
2434 # Create an instance of BlinkStick. Note that we do not use the mock, or pass a device.
2535 # This is deliberate, as we want to test that all methods raise an exception when the backend is not set.
2636 bs = BlinkStick ()
27-
28- class_methods = (
29- method
30- for method in dir (BlinkStick )
31- if callable (getattr (bs , method )) and not method .startswith ("__" )
32- )
33- for method_name in class_methods :
34- method = getattr (bs , method_name )
35- with pytest .raises (NotConnected ):
36- method ()
37+ method = getattr (bs , method_name )
38+ with pytest .raises (NotConnected ):
39+ method ()
3740
3841
3942@pytest .mark .parametrize (
You can’t perform that action at this time.
0 commit comments