diff options
| author | Tim Graham <timograham@gmail.com> | 2014-11-29 11:45:06 -0500 |
|---|---|---|
| committer | Tim Graham <timograham@gmail.com> | 2014-12-01 16:08:25 -0500 |
| commit | 82e4f956e3faa4a48fe3c90e02673c1a916d6943 (patch) | |
| tree | aa8aaeb1a2aaa1dc9ccad5f764ff10b4abf6dc49 /tests | |
| parent | 43fcf3505eb22228f551ab03122f99b3d40f38ed (diff) | |
Fixed #23289 -- Added mock as a test dependency.
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/README.rst | 2 | ||||
| -rw-r--r-- | tests/requirements/base.txt | 2 | ||||
| -rwxr-xr-x | tests/runtests.py | 10 | ||||
| -rw-r--r-- | tests/test_runner/tests.py | 10 |
4 files changed, 17 insertions, 7 deletions
diff --git a/tests/README.rst b/tests/README.rst index 1a12cad3fa..73bce435e2 100644 --- a/tests/README.rst +++ b/tests/README.rst @@ -1,5 +1,7 @@ To run the test suite:: + $ cd tests + $ pip install -r requirements/py3.txt # or py2.txt $ PYTHONPATH=..:$PYTHONPATH ./runtests.py For more information about the test suite, see diff --git a/tests/requirements/base.txt b/tests/requirements/base.txt index c3f77234fd..c38e8695aa 100644 --- a/tests/requirements/base.txt +++ b/tests/requirements/base.txt @@ -1,5 +1,7 @@ bcrypt docutils +# move to py2.txt when dropping Python 3.2 +mock numpy Pillow PyYAML diff --git a/tests/runtests.py b/tests/runtests.py index a336b7f6d2..1ae7c93150 100755 --- a/tests/runtests.py +++ b/tests/runtests.py @@ -374,6 +374,16 @@ if __name__ == "__main__": help='Run the Selenium tests as well (if Selenium is installed)') options = parser.parse_args() + # mock is a required dependency + try: + from django.test import mock # NOQA + except ImportError: + print( + "Please install test dependencies first: \n" + "$ pip install -r requirements/py%s.txt" % sys.version_info.major + ) + sys.exit(1) + # Allow including a trailing slash on app_labels for tab completion convenience options.modules = [os.path.normpath(labels) for labels in options.modules] diff --git a/tests/test_runner/tests.py b/tests/test_runner/tests.py index d38d27f30c..a8ce8d947c 100644 --- a/tests/test_runner/tests.py +++ b/tests/test_runner/tests.py @@ -10,7 +10,7 @@ from django.conf import settings from django.core.exceptions import ImproperlyConfigured from django.core.management import call_command from django.db.backends.dummy.base import DatabaseCreation -from django.test import TestCase, TransactionTestCase, skipUnlessDBFeature +from django.test import TestCase, TransactionTestCase, mock, skipUnlessDBFeature from django.test.runner import DiscoverRunner, dependency_ordered from django.test.testcases import connections_support_transactions from django.utils import six @@ -129,13 +129,10 @@ class DependencyOrderingTests(unittest.TestCase): class MockTestRunner(object): - invoked = False - def __init__(self, *args, **kwargs): pass - def run_tests(self, test_labels, extra_tests=None, **kwargs): - MockTestRunner.invoked = True +MockTestRunner.run_tests = mock.Mock(return_value=[]) class ManageCommandTests(unittest.TestCase): @@ -143,8 +140,7 @@ class ManageCommandTests(unittest.TestCase): def test_custom_test_runner(self): call_command('test', 'sites', testrunner='test_runner.tests.MockTestRunner') - self.assertTrue(MockTestRunner.invoked, - "The custom test runner has not been invoked") + MockTestRunner.run_tests.assert_called_with(('sites',)) def test_bad_test_runner(self): with self.assertRaises(AttributeError): |
