python - Pytests import fails after renaming project folder -
i've been struggling while renaming project folder of python project. called foo , want rename bar.
foo/ /src __init__.py x.py /test __init__.py x_test.py __init__.py
became
bar/ /src __init__.py x.py /test __init__.py x_test.py __init__.py
when project folder named foo tests passed, after renaming bar tests don't work anymore. imports raise importerror: no module src.x
.
i can import module when i'm using python console:
$ python >>> import src.x
when rename bar foo , run test i'll error:
import file mismatch: imported module 'test.x' has __file__ attribute: /home/orangetux/projects/foo/test/x_test.py not same test file want collect: /home/orangetux/projects/bar/test/x_test.py hint: remove __pycache__ / .pyc files and/or use unique basename test file modules
i can fix removing __pycache__
folders. i'm @ start. folder named foo working test. how rename project folder bar , keep working tests?
delete python cache (__pycache__
) , "compiled" files (ie: *.pyc, *.pyo).
make sure __init.py__
files not referring folder or path.
Comments
Post a Comment