MCPcopy Create free account
hub / github.com/FastLED/FastLED / run_tests

Function run_tests

ci/test_rpc_edge_cases.py:241–310  ·  view source on GitHub ↗

Run all test cases and return (passed, failed) counts.

()

Source from the content-addressed store, hash-verified

239
240
241def run_tests() -> tuple[int, int]:
242 """Run all test cases and return (passed, failed) counts."""
243 passed = 0
244 failed = 0
245
246 print("=" * 80)
247 print("RPC EDGE CASE TESTING")
248 print("=" * 80)
249 print()
250
251 for i, test in enumerate(TEST_CASES, 1):
252 print(f"Test {i}/{len(TEST_CASES)}: {test.name}")
253 print(
254 f" JSON: {test.json_response[:80]}{'...' if len(test.json_response) > 80 else ''}"
255 )
256
257 try:
258 # Extract expected ID from JSON (or use test index if no ID)
259 test_data = json.loads(test.json_response)
260 expected_id = test_data.get("id", i)
261
262 # Parse the response
263 response = parse_response_like_client(
264 test.json_response, expected_id=expected_id
265 )
266
267 # Verify success field
268 if response.success != test.expected_success:
269 print(
270 f" ❌ FAIL: Expected success={test.expected_success}, got {response.success}"
271 )
272 failed += 1
273 continue
274
275 # Verify data type
276 if not isinstance(response.data, test.expected_data_type):
277 print(
278 f" ❌ FAIL: Expected data type {test.expected_data_type.__name__}, got {type(response.data).__name__}"
279 )
280 failed += 1
281 continue
282
283 # Verify data content
284 if response.data != test.expected_data:
285 print(
286 f" ❌ FAIL: Expected data {test.expected_data}, got {response.data}"
287 )
288 failed += 1
289 continue
290
291 print(f" ✅ PASS")
292 passed += 1
293
294 except KeyboardInterrupt as ki:
295 handle_keyboard_interrupt(ki)
296 raise
297 except Exception as e:
298 if test.should_raise is not None and isinstance(e, test.should_raise):

Callers 1

mainFunction · 0.70

Calls 4

printFunction · 0.50
getMethod · 0.45

Tested by

no test coverage detected