So, I have a Django-REST Framework project and one day it simply ceased being able to run the tests within PyCharm.
From the command line I can run them both using paver
or the manage.py
directly.
There was a time when that would happen when we didn't import the class' superclass at the top of the file, but that's not the case.
We have a virtualenv
set locally and run the server from a vagrant box. I assured the virtual environment is loaded and that the project's Interpreter is using the afore mentioned virtual env.
No clue on what's the matter.
Given all the others paths were already covered:
- Import order
- Virtual Env created
- Project's Interpreter using the Virtual Env
The only thing that occurred to me was do run the following command within the vurtal env:
pip install -r requirements.txt
And it worked! In the end, someone had updated the requirements which weren't being met by my current virtual env. Screwing up with the paths/imports within PyCharm.
I had the same problem but my solution was different.
When I tried to run a test from PyCharm, the target path looked like this:
- tests.apps.an_app.models.a_model.ATestCase
But since ATest was a class inside a_model.py, the targ path should actually be:
- tests.apps.an_app.models.a_model:ATestCase
Changing the target in the test configuration worked.