如图,使用 pyinstaller 打包测试后,在调用 pytest.main()时,运行后提示如下:
ERROR: usage: run_main.exe [options] [file_or_dir] [file_or_dir] [...]
run_main.exe: error: unrecognized arguments: --alluredir=W:\StudyLibrary\csc-rms-apitest\dist\run_main\reports\result\2020-04-22 inifile: None rootdir: W:\StudyLibrary\csc-rms-apitest\dist\run_main
pytest 调用如下:
def m_run(case_path, allure_path, test_count, allure_report_path):
pytest.main(['-v',
'-s',
case_path,
'--alluredir',allure_path,
'--count', str(test_count),
'--repeat-scope=function',
'--disable-warnings',
'--capture=no',
])
pyinstaller 的 spec 文件如下:
block_cipher = None
a = Analysis(['D:\\mytools\\SmokingTestCase_for_exe\\run_ui.py'],
pathex=['C:\\Users\\Dell','D:\\mytools\\SmokingTestCase_for_exe',
'D:\\mytools\\python\\python3_7\Lib\\site-packages'],
binaries=[],
datas=[('D:\\mytools\\SmokingTestCase_for_exe\\testcase\\*.py',
'testcase'),
('D:\\mytools\\SmokingTestCase_for_exe\\testdata\\*.yaml',
'testdata'),
('D:\\mytools\\SmokingTestCase_for_exe\\page\\*.py',
'page'),
('D:\\mytools\\SmokingTestCase_for_exe\\*.py',
'.'),
],
hiddenimports=['page','myemail','mylog'],
hookspath=[],
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher,
noarchive=False)
pyz = PYZ(a.pure, a.zipped_data,
cipher=block_cipher)
exe = EXE(pyz,
a.scripts,
a.binaries,
a.zipfiles,
a.datas,
[],
name='run_ui',
debug=True,
bootloader_ignore_signals=False,
strip=False,
upx=True,
upx_exclude=[],
runtime_tmpdir=None,
console=True )
完全没头绪为什么会出现这种情况,去除 -allure 和--count 两个参数就能正常运行,求大佬帮助