@@ -45,7 +45,7 @@ def iter_scenario_tests():
4545 modes = [m for m in modes if m == "hardware" ]
4646 for mode in modes :
4747 test_id = f"{ name } /{ test ['name' ]} /{ mode } "
48- marks = [pytest .mark .board ] if is_board else []
48+ marks = [pytest .mark .board , pytest . mark . hardware ] if is_board else []
4949 yield pytest .param (scenario , test , mode , id = test_id , marks = marks )
5050
5151
@@ -89,66 +89,75 @@ def test_scenario(scenario, test, mode, port):
8989 bridge = MpremoteBridge (port = port )
9090 action = test ["action" ]
9191
92+ is_board = scenario .get ("type" ) == "board"
93+
9294 if action == "manual" :
9395 # Skip manual tests when stdin is not available (no -s flag)
9496 import sys
9597 if not sys .stdin .isatty ():
9698 pytest .skip ("manual test requires interactive mode (-s)" )
9799
98100 # Display values before prompting if 'display' is defined
99- for display in test .get ("display" , []):
100- value = bridge .call_method (
101+ # (board scenarios have no driver, so display is not supported)
102+ if not is_board :
103+ for display in test .get ("display" , []):
104+ value = bridge .call_method (
105+ scenario ["driver" ],
106+ scenario ["driver_class" ],
107+ scenario ["i2c" ],
108+ display ["method" ],
109+ display .get ("args" ),
110+ module_name = scenario .get ("module_name" ),
111+ hardware_init = scenario .get ("hardware_init" ),
112+ i2c_address = scenario .get ("i2c_address" ),
113+ )
114+ label = display .get ("label" , display ["method" ])
115+ unit = display .get ("unit" , "" )
116+ if isinstance (value , float ):
117+ print (f" { label } : { value :.2f} { unit } " )
118+ else :
119+ print (f" { label } : { value } { unit } " )
120+ prompt = test .get ("prompt" , "Manual check" )
121+ result = prompt_yes_no (prompt )
122+ elif action in ("call" , "read_register" , "interactive" ):
123+ if is_board :
124+ pytest .fail (
125+ f"Board scenarios do not support '{ action } ' action; "
126+ f"use 'hardware_script' or 'manual' instead"
127+ )
128+ if action == "call" :
129+ result = bridge .call_method (
101130 scenario ["driver" ],
102131 scenario ["driver_class" ],
103132 scenario ["i2c" ],
104- display ["method" ],
105- display .get ("args" ),
133+ test ["method" ],
134+ test .get ("args" ),
135+ module_name = scenario .get ("module_name" ),
136+ hardware_init = scenario .get ("hardware_init" ),
137+ i2c_address = scenario .get ("i2c_address" ),
138+ )
139+ elif action == "read_register" :
140+ result = bridge .read_register (
141+ scenario ["i2c" ],
142+ scenario ["i2c_address" ],
143+ test ["register" ],
144+ )
145+ else : # interactive
146+ import sys
147+ if not sys .stdin .isatty ():
148+ pytest .skip ("interactive test requires interactive mode (-s)" )
149+ pre_prompt = test .get ("pre_prompt" , "Perform action then press Enter" )
150+ input (f" [INTERACTIVE] { pre_prompt } " )
151+ result = bridge .call_method (
152+ scenario ["driver" ],
153+ scenario ["driver_class" ],
154+ scenario ["i2c" ],
155+ test ["method" ],
156+ test .get ("args" ),
106157 module_name = scenario .get ("module_name" ),
107158 hardware_init = scenario .get ("hardware_init" ),
108159 i2c_address = scenario .get ("i2c_address" ),
109160 )
110- label = display .get ("label" , display ["method" ])
111- unit = display .get ("unit" , "" )
112- if isinstance (value , float ):
113- print (f" { label } : { value :.2f} { unit } " )
114- else :
115- print (f" { label } : { value } { unit } " )
116- prompt = test .get ("prompt" , "Manual check" )
117- result = prompt_yes_no (prompt )
118- elif action == "call" :
119- result = bridge .call_method (
120- scenario ["driver" ],
121- scenario ["driver_class" ],
122- scenario ["i2c" ],
123- test ["method" ],
124- test .get ("args" ),
125- module_name = scenario .get ("module_name" ),
126- hardware_init = scenario .get ("hardware_init" ),
127- i2c_address = scenario .get ("i2c_address" ),
128- )
129- elif action == "read_register" :
130- result = bridge .read_register (
131- scenario ["i2c" ],
132- scenario ["i2c_address" ],
133- test ["register" ],
134- )
135- elif action == "interactive" :
136- # Prompt user first, then call method
137- import sys
138- if not sys .stdin .isatty ():
139- pytest .skip ("interactive test requires interactive mode (-s)" )
140- pre_prompt = test .get ("pre_prompt" , "Perform action then press Enter" )
141- input (f" [INTERACTIVE] { pre_prompt } " )
142- result = bridge .call_method (
143- scenario ["driver" ],
144- scenario ["driver_class" ],
145- scenario ["i2c" ],
146- test ["method" ],
147- test .get ("args" ),
148- module_name = scenario .get ("module_name" ),
149- hardware_init = scenario .get ("hardware_init" ),
150- i2c_address = scenario .get ("i2c_address" ),
151- )
152161 elif action == "hardware_script" :
153162 import sys
154163 if not sys .stdin .isatty ():
@@ -159,7 +168,7 @@ def test_scenario(scenario, test, mode, port):
159168 input (f" [INTERACTIVE] { pre_prompt } " )
160169 else :
161170 print (f" [INTERACTIVE] { pre_prompt } " )
162- if scenario . get ( "type" ) == "board" :
171+ if is_board :
163172 result = bridge .run_raw_script (test ["script" ])
164173 else :
165174 result = bridge .run_script (
0 commit comments