2

I'm using Python 3.3 on Win7, and I'm fairly new to testing and py.test. I have a simple test to run, and although I can run it from the command line by calling

$ python -m pytest testing.py 

when trying to call it with the simpler line

$ py.test testing.py

it returns:

'py.test' is not recognized as an internal or external command, 
operable program, or batch file

Do I need to have the py.test source folder in the same location as my program, or am I doing something incorrectly?

trobe
  • 21
  • 1
  • 2

3 Answers3

1

The system is telling you:

  • py.test is not installed in a standard location. If you installed using pip or easy-install, it should be in /usr/local/bin or possibly /opt/bin depending on your flavour of Linux, and these should be on your path.
  • py.test has not been marked as executable.
  • You installed from source using setup.py and the directory containing py.test is not on your path, probably in or below your home directory.

Check for these possibilities, correct them if necessary and post the results of your efforts.

Jonathan
  • 1,917
  • 1
  • 23
  • 35
0

Above one is true.

Try to create a new virtual environment and do a new py.test

And check your python installation and path if the executable is accessible by terminal

William Prigol Lopes
  • 1,611
  • 10
  • 22
  • "above one" is an unreliable reference. You are aware that the order of posts can be configured inidividually by users, aren't you? Your post could therefor appear below the most useless and wrong answer. – Yunnosch Oct 01 '20 at 18:43
0
pip install pytest==6.2.1 

It worked for me.

pip install pytest== (any pytest version number)
Ann Zen
  • 17,892
  • 6
  • 20
  • 39