Hi, at my first contact with CI I run into troubles while setting up an test coverage analysis. My local test runs fine within it’s virtualenv: coverage run manage.py test --settings papersquirrel.settings.ci .
But when I setup travis, I get an error:
ModuleNotFoundError: No module named ‘papersquirrel.settings.ci’
I tried various options and constellations, but it seems that I didn’t understand some aspects of the python path
My guess is: you need to add the current directory to Python path:
- export PYTHONPATH="$(pwd)"
- coverage <etc>
As per
you are running manage.py through coverage – a wrapper over a Python script. So the directory where that wrapper is located is added to sys.path instead of the current directory.
and checked the variable via echo. It looks good and includes the directory of my project. Also just invoking python manage.py test results in this issue …
I also tried to rollout the repo on another server to avoid bugs due local artifacts, but also on that server everything works fine.
Sorry, but any further ideas?
Well, debugging is the further idea. It’s always the same:
Identify the exact place in the code where the error manifests itself
Examine the program’s state at that moment to find out which of the values is wrong
Track the wrong value back to its origin
You can insert debug printing into files if you know how to do that on the fly, or request debug mode for your project and edit the code by hand or run it under debugger.
Well, 40+ builds later and trying different ideas, but I didn’t solved the problem yet and I’m close to give up
First I just try to run only the testsuites itself, but n
All in all, this seems to be a problem with the import path, but I checked, that the project root folder and the settings subfolder are on the paths:
If I skip the --settingsparameter, the suite runs as expected, but of course it doesn’t has the right settings to do it’s job.
I also tried different other approaches, that say it’s a problem of the travis virtualenv or to find my module itself:
God damnit, you are right! My .gitignore blocked the settings file and my test on another server was with a custom local settings file …
Sometimes it’s the most basic things … thank you very much!