1

I have been trying to bundle my tests written on pytest as .exe file.

I have tried the code mentioned in the pytest documentation for including the third party plugins: https://docs.pytest.org/en/latest/example/simple.html#freezing-pytest

My code is as follows:

import pytest
import xdist
import pytest_rerunfailures

if len(sys.argv) > 1 and sys.argv[1] == "--pytest":
    sys.exit(pytest.main(sys.argv[2:], plugins=[xdist, pytest_rerunfailures]))

Interestingly, the code works for pytest_rerunfailures but when I run the .exe using -n 2, it shows the following error:

ERROR: usage: mainfile [options] [file_or_dir] [file_or_dir] [...]
mainfile: error: unrecognized arguments: -n
  inifile: None
  rootdir: A:\New folder (2)\Scripted\dist

Here mainfile is the name of the exe file.

Also, it would be worth mentioning that xdist command-line options work when the tests are run normally but when bundled as exe, the create this issue.

ModuleNotFoundError: No module named 'execnet.rsync'

Could someone help me out here?

0 Answers0