I am trying to learn CircleCI but must say, finding it very difficult to use. I am trying to run my Selenium project code written in Python language but getting pytest: command not found error. I have mentioned the PyTest installation in my requirement.txt file, I also tried to install the PyTest by running the below command but still getting the same error.
- run: pip install pytest --user
Here is my config.yml file
version: 2.1
orbs:
python: circleci/[email protected]
jobs:
example-job:
docker:
- image: circleci/python:3.6.1
steps:
- checkout
- run: pip install pytest --user
- python/install-packages:
args: pytest --user
pkg-manager: pip
pypi-cache: false
- run:
command:
pytest businessObjects/test_Login.py
workflows:
example-workflow:
jobs:
- example-job
Error is
#!/bin/bash -eo pipefail
pytest businessObjects/test_Login.py
/bin/bash: pytest: command not found
Exited with code exit status 127
CircleCI received exit code 127
It must be some basic mistake but tried a lot and am now stuck. Any help is appreciated. Thanks
CodePudding user response:
The easier way to deal with these kind of issue with circleci is to use the option "ReRun job with SSH"
This would allow you to login to the circleci build instance and try out the installation commands
pip install pytest --user
or
python -m pip install pytest
or any command which would fix the issue
The command with which you do not get the error pytest is invalid command , can be used in circleci config
CodePudding user response:
Finally was able to run my code in CircleCI. Posting my config.yml here in case someone else needs help. Thanks, @jortega for trying to help, appreciate your effort.
version: 2.1
orbs:
python: circleci/[email protected]
jobs:
build_and_test: # this can be any name you choose
executor: python/default
steps:
- checkout
- python/install-packages:
pkg-manager: pip
- run:
name: Run tests
command: python -m pytest
- persist_to_workspace:
root: ~/project
paths: businessObjects
- .
workflows:
test_my_app:
jobs:
- build_and_test