pyinstaller 打包 pytest+allure 自动化测试框架后运行报错,请大牛指教

2020-04-22 12:16:46 +08:00
 Ctry

如图,使用 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 两个参数就能正常运行,求大佬帮助

2017 次点击
所在节点    Python
0 条回复

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/664944

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX