You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

运行mut.py出现未知参数错误,期望正常启动变异测试

mut.py 参数错误解决方法

你运行的命令中使用了mut.py不识别的参数--dcmotor_pid_control和--dcmotor_tests,导致报错:

C:\Pprogs>mut.py --dcmotor_pid_control --dcmotor_tests -m
usage: mut.py [-h] [--version] [--target TARGET [TARGET ...]] [--unit-test UNIT_TEST [UNIT_TEST ...]] [--runner RUNNER]
              [--report REPORT_FILE] [--report-html DIR_NAME] [--timeout-factor TIMEOUT_FACTOR] [--show-mutants] [--quiet]
              [--debug] [--colored-output] [--disable-stdout] [--experimental-operators] [--operator OPERATOR [OPERATOR ...]]
              [--disable-operator OPERATOR [OPERATOR ...]] [--list-operators] [--path DIR] [--percentage PERCENTAGE] [--coverage]
              [--order ORDER] [--hom-strategy HOM_STRATEGY] [--list-hom-strategies] [--mutation-number MUTATION_NUMBER]
mut.py: error: unrecognized arguments: --dcmotor_pid_control --dcmotor_tests

你期望的执行结果是:

[*] Start mutation process:
- targets: dcmotor_pid_control
- tests: dcmotor_tests
[*] All tests passed:

解决方法

使用mut.py官方定义的参数格式,通过--target指定要变异的目标代码,--unit-test指定对应的测试文件,正确命令如下:

mut.py --target dcmotor_pid_control --unit-test dcmotor_tests -m

mut.py没有直接以目标/测试文件名作为参数的选项,必须通过--target和--unit-test这两个选项传递对应内容,这样就能触发你期望的变异流程。

内容的提问来源于stack exchange,提问作者DeReK YuEn

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.24 00:42:10