Uprade Django 1.6.5 to 1.7 - tests not working now

I took the plunge to upgrade the virtual environment for our project from Django 1.6.5 to Django 1.7.

When I use the menu to run Tools | Run manage.py Task then select "test" the tests don't run, with the message:

/Users/jamesk/upharm27/lib/python2.7/site-packages/django/test/_doctest.py:62: RemovedInDjango18Warning: The django.test._doctest module is deprecated; use the doctest module from the Python standard library instead.

To figure out what was causing this, I put the following lines in django.test._doctest, immediately before the warning command:

import traceback

It shows (in part) the following:

  File "/Applications/PyCharm.app/helpers/pycharm/django_test_runner.py", line 30, in <module>
    from django.test.simple import DjangoTestSuiteRunner
  File "/Users/jamesk/upharm27/lib/python2.7/site-packages/django/test/simple.py", line 13, in <module>
    from django.test import _doctest as doctest
  File "/Users/jamesk/upharm27/lib/python2.7/site-packages/django/test/_doctest.py", line 57, in <module>

Which I interpret as PyCharm's django_test_runner.py imporint django.test.simple, which triggers the deprecation warning.

What would be recommended here? It would appear to my untrained eyes that PyCharm's helper script is out of date for Django 1.7, but I'm not entirely sure.

Thank you!

OS: OS X 10.9.4
Pycharm: 3.4.1
Python: 2.7.6 in virtual environment.

I have the same issues. The tests work in some cases, but not in all. Of course the ones they don't work in are the ones I need too!
I ended up doing a rough hack of the PyCharm helper script so 1.7 testing works again. I can share diffs if it might be useful.
Yes I'd like to see some diffs to workaround this until there is an official response from Jetbrains.
Was there a solution to this problem?
No solution, just a workaround.

**facepalm** Like an idiot I didn't do a copy before I edited the helper so I can't do the diff as I had thought I would.

I can jog things around to get the diffs against a fresh install of PyCharm, but I'm not in a position where I can do it at this moment.
All right, these are the files that I've had to tweak.

The following allows the Django shell within PyCharm to have Django loaded.

> import django
> django.setup()

This is an incomplete attempt to patch the Django test runner so it'll still work with older Django versions, but I never got back to it.

However it works fine with Django 1.7 and I'm able to run unit tests.

The important point is that django.tests.testcases should not be used. Rather, the standard Python unittest.TestCase should be used.

< from django.test.testcases import TestCase
> from unittest import TestCase
< try:
<   from django.utils import unittest
< except ImportError:
<   import unittest
> if VERSION[0] > 1 or VERSION[0] == 1 and VERSION[1] >= 8:
>     import unittest
> else:
>     try:
>       from django.utils import unittest
>     except ImportError:
>       import unittest
<   from django.test.simple import DjangoTestSuiteRunner
>   from django.test.runner import DiscoverRunner
<   BaseSuiteRunner = SUITE_RUNNER or DjangoTestSuiteRunner
>   BaseSuiteRunner = SUITE_RUNNER or DiscoverRunner

I hope this is helpful.
Additionally, if you use Sphinx to produce documentation, you'll need to activate Django in the helper:

< import django
< django.setup()
When I run my tests in a python script it modifies my production database. If I run from the command line it doesn't. When I say modify, it wipes out my existing users and replaces them with the users I create for testing.
Ripelnet, personally that seems serious enough for its own discussion thread to get some attention. It appears that there are two bugs in youtrack to take care of the issue in this thread.

Please sign in to leave a comment.