简体   繁体   English

pytest中断:ImportError“没有名为质数的模块”

[英]pytest Interrupted: ImportError “No module named primes”

I have changed the sys.path to ../mypkg in the test_primes.py and it works when I execute it separately (without pytest) - 我已经在../mypkg中将sys.path更改为../mypkg ,并且当我单独执行它(没有pytest)时它可以工作-

python test_primes.py python test_primes.py

But, when I do 但是,当我这样做

py.test py.test

in the src, it doesn't work 在src中,它不起作用

PLEASE CHECK OUT THE IMAGE FOR THE DETAILED ERROR 请检查图像中的详细错误

pytest image pytest图片

from mypkg.primes import is_prime您停止修改sys.path ,它应该可以正常工作,而实际上是从包中from mypkg.primes import is_primefrom mypkg.primes import is_prime

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM