Skip to content

Commit

Permalink
Use the new unittest2 when running via setup.py or via external test …
Browse files Browse the repository at this point in the history
…tools

git-svn-id: https://svn.pyamf.org/branches/test-discovery-780@3367 2dde4cc4-cf3c-0410-b1a3-a9b8ff274da5
  • Loading branch information
njoyce committed Jun 7, 2010
1 parent 27ab5d5 commit 677d9d1
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
9 changes: 8 additions & 1 deletion pyamf/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,14 @@

import os.path

import unittest
try:
import unittest2 as unittest
import sys

sys.modules['unittest'] = unittest
except ImportError:
import unittest


def get_suite():
"""
Expand Down
20 changes: 20 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import sys, os.path

from setuptools import setup, find_packages, Extension
from setuptools.command import test

try:
from Cython.Distutils import build_ext
Expand All @@ -34,6 +35,24 @@
del sys.modules[k]


class TestCommand(test.test):
"""
Ensures that unittest2 is imported if required and replaces the old
unittest module.
"""

def run_tests(self):
try:
import unittest2
import sys

sys.modules['unittest'] = unittest2
except ImportError:
pass

return test.test.run_tests(self)


def get_cpyamf_extensions():
"""
Returns a list of all extensions for the cpyamf module. If for some reason
Expand Down Expand Up @@ -139,6 +158,7 @@ def get_test_requirements():
platforms = ["any"],
cmdclass = {
'build_ext': build_ext,
'test': TestCommand
},
extras_require = {
'wsgi': ['wsgiref'],
Expand Down

0 comments on commit 677d9d1

Please sign in to comment.