Generate test functions dynamically for each test case
()
| 271 | |
| 272 | # Generate individual test functions for pytest |
| 273 | def generate_test_functions(): |
| 274 | """Generate test functions dynamically for each test case""" |
| 275 | for i, test_case in enumerate(TEST_CASES): |
| 276 | # Create a test function for this case |
| 277 | async def test_func(): |
| 278 | await test_cli_mapping(test_case) |
| 279 | |
| 280 | # Set function name and docstring |
| 281 | test_func.__name__ = f"test_cli_case_{i+1}_{test_case.name.replace(' ', '_').lower()}" |
| 282 | test_func.__doc__ = f"Test {i+1}: {test_case.name}" |
| 283 | |
| 284 | # Add to module globals so pytest can find it |
| 285 | globals()[test_func.__name__] = pytest.mark.asyncio(test_func) |
| 286 | |
| 287 | |
| 288 | # Generate the test functions |