construct argv by configs Args: config (dict): the config data Returns: list[str]: the argvs
(config: dict)
| 363 | |
| 364 | |
| 365 | def construct_argv(config: dict) -> list[str]: |
| 366 | """construct argv by configs |
| 367 | |
| 368 | Args: |
| 369 | config (dict): the config data |
| 370 | |
| 371 | Returns: |
| 372 | list[str]: the argvs |
| 373 | """ |
| 374 | # get current test |
| 375 | # refer to: https://docs.pytest.org/en/latest/example/simple.html#pytest-current-test-environment-variable |
| 376 | current_test = "tests/__init__.py" |
| 377 | if "PYTEST_CURRENT_TEST" in os.environ: |
| 378 | current_test = os.getenv("PYTEST_CURRENT_TEST").split("::")[0] |
| 379 | |
| 380 | argv = [current_test] |
| 381 | for key, value in config.items(): |
| 382 | argv.append(f"--{key}") |
| 383 | argv.append(str(value)) |
| 384 | |
| 385 | return argv |
| 386 | |
| 387 | |
| 388 | @contextmanager |
no test coverage detected