0

I have changed the sys.path to ../mypkg in the test_primes.py and it works when I execute it separately (without pytest) -

python test_primes.py

But, when I do

py.test

in the src, it doesn't work

PLEASE CHECK OUT THE IMAGE FOR THE DETAILED ERROR

pytest image

Vijeth Aradhya
  • 268
  • 2
  • 11
  • You probably need `python -m unittest`, see http://stackoverflow.com/a/24266885/3025981 – Ilya V. Schurov Oct 29 '16 at 22:28
  • "in the source" - what is your current directory when you do that? "../mypkg" only works from one directory. Consider taking that out completely and setting an environment variable when you test. `PYTHONPATH=path/to/pkgroot:$PYTHONPATH py.test` on linuxy systems. – tdelaney Oct 29 '16 at 23:03

1 Answers1

0

I'd guess it should work fine when you stop modifying sys.path, and actually import from your package instead: from mypkg.primes import is_prime.

The Compiler
  • 11,126
  • 4
  • 40
  • 54