Search code examples
pythonpytestpyinstaller

Execute pytest via pyinstaller created exe extension file


I had made more than 1 pytest test files I needed it to be convert them to a single exe file

  1. I used pyinstaller for that not able to convert the test cases to .exe file

  2. Even though if some how I will convert it I could not run it via clicking on .exe file as on console I am running it by python -m pytest

So Please help me guys


Solution

  • Create a bat file rather, if you want to run it on a windows environment. Keep the required libraries ( like pytest, selenium.. etc) in a requirements.txt file in root directory. Keep the bat file with the root directory. The commands in the bat file will go as below.

    cd path/to/current/directory &
    virtualenv env &
    "cmd.exe" "\c .env/Scripts/Activte && pip install -r 
    requirements.txt && pytes  your commands to trigger script 
    here" 
    

    Once you hit the bat the dependent Libraries will be installed and later your scripts will trigger