Skip to content
Advertisement

Getting an error “pytest: command not found” while running a Python test from CircleCI

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/python@2.0.3


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

Advertisement

Answer

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/python@2.0.3
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     
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement