Browse files

[soc2010/test-refactor] Unittest2 integration properly done. unittest…

…2 package (at rev 221) is bundled as django.utils.unittest and the imports are patched to reflect django usage. Tests should import django.utils.unittest rather than the stdlib package. "It's a beautiful thing, the destruction of doctests."

git-svn-id: bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
1 parent 1548081 commit 86580d042ecc12e0e34f369edee9bf9b71ade816 @PaulMcMillan PaulMcMillan committed Jul 2, 2010
@@ -1,12 +1,12 @@
import sys
import signal
-import unittest
from django.conf import settings
from django.db.models import get_app, get_apps
from django.test import _doctest as doctest
from django.test.utils import setup_test_environment, teardown_test_environment
from django.test.testcases import OutputChecker, DocTestRunner, TestCase
+from django.utils import unittest
# The module name for tests outside
TEST_MODULE = 'tests'
@@ -1,8 +1,9 @@
import re
-import unittest2 as unittest
from urlparse import urlsplit, urlunsplit
from xml.dom.minidom import parseString, Node
+#from django.utils import unittest
from django.conf import settings
from django.core import mail
from import call_command
@@ -11,7 +12,7 @@
from django.http import QueryDict
from django.test import _doctest as doctest
from django.test.client import Client
-from django.utils import simplejson
+from django.utils import simplejson, unittest
from django.utils.encoding import smart_str
@@ -0,0 +1,14 @@
+import sys
+#Django hackery to load the appropriate version of unittest
+if sys.version_info >= (2,7):
+ #unittest2 features are native in Python 2.7
+ from unittest import *
+ try:
+ #check the system path first
+ from unittest2 import *
+ except ImportError:
+ #otherwise fall back to our bundled version
+ from unittest2_package_init import *
@@ -0,0 +1,10 @@
+"""Main entry point"""
+import sys
+if sys.argv[0].endswith(""):
+ sys.argv[0] = "unittest2"
+__unittest = True
+from django.utils.unittest.main import main_
Oops, something went wrong.

0 comments on commit 86580d0

Please sign in to comment.