I'm having an hard time trying to run my Django tests using PyCharm. I did it easily in the past using a "python running configuration" in which I used manage.py
to run them, I was on OSX and using python 2.7, Django <= 1.7, Pycharm <= 4. Now I'm on Linux Mint, I use Python 3.4.3, Django 1.8.2 and Pycharm 4.5. I always used virtualenv to manage my projects. Now by running "manage.py test" from Pycharm no tests are found (it prints "Empty test suite"). But tests exist, and if I run the command from the shell they get executed. So I really don't understand what's going on. I'm actually able to launch tests using "an hack" I created, but the problem is that Pycharm is not able to attach to the process in order to allow breakpoints in tests (which is one of the features I use the most!). My "hack" is the following:
I created a python script with:
import subprocess
def main():
subprocess.call('./venv_activator.sh', shell=True)
if __name__ == '__main__':
main()
then a bash script (venv_activator.sh
):
#!/usr/bin/env bash
source .ENV/bin/activate
python manage.py test myapp -p "*_tests.py" --noinput -v 2 --settings=settings.test
In practice the python script is used to create a "python running configuration" for Pycharm, then it activate the virtualenv and invokes the django test command.
ps: yes, I turned on "Django support" in PyCharm (and I configured the python interpreter under the virtualenv)
Aucun commentaire:
Enregistrer un commentaire