You can use the attached code to reproduce the issue.
On Monday, July 20, 2020 at 1:29:43 PM UTC+3, Avi Uziel wrote:
>
> Hi all,
>
> I have an application that execute pytest.main().
>
> simplified code snippet:
> ---
> import pytest
> import pytest_html
>
> def run_tests(test_func):
> test_module = os.path.join(sys._MEIPASS, "tests.py")
> return pytest.main(["-vvv", "-p", "pytest_html", "--html=report.html",
> "--capture=tee-sys", test_module])
> ---
>
> The result is that pytest-html plugin fails to load:
> ----
> ERROR: usage: aidoc-probe.exe [options] [file_or_dir] [file_or_dir] [...]
> aidoc-probe.exe: error: unrecognized arguments: --html=report.html
> inifile: None
> rootdir: D:\prob-test
> ----
> Running the same code without ["-p", "pytest_html", "--html=report.html"]
> run as expected and I have the standard pytest output.
>
> I running pyinstaller on Windows box, using conda environment.
> In the environment I have pytest-html package installed.
>
> Any help will be appreciated.
>
> Thanks,
> Avi
>
--
You received this message because you are subscribed to the Google Groups
"PyInstaller" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/pyinstaller/a73a1b22-2fcd-461d-a157-262b1ade7fdbo%40googlegroups.com.
# create venv and install pytest, pytest-html.
# activate venv and generate exe by using:
# pyinstaller --onefile --noconfirm --nowindow --exclude-module PyQt5 --add-data "poc.py;." poc.py
import os
import sys
import pytest
import pytest_html
def test_helloworld():
assert True
def resource_path(relative):
"""
pyinstaller unpacks data into a temporary folder,
and stores this directory path in the _MEIPASS environment variable.
relative - name of the resource
"""
try:
if getattr(sys, 'frozen') and hasattr(sys, '_MEIPASS'):
return os.path.join(sys._MEIPASS, relative)
except:
return os.path.join(os.path.abspath("."), relative)
# not working:
pytest.main(["-vvv", "-p", "pytest_html", "--html=report.html", resource_path(__file__)])
# working:
# pytest.main(["-vvv", resource_path(__file__)])