Commit 82e4f956 authored by Tim Graham's avatar Tim Graham
Browse files

Fixed #23289 -- Added mock as a test dependency.

parent 43fcf350
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -16,3 +16,12 @@ __all__ = [
    'skipUnlessDBFeature', 'modify_settings', 'override_settings',
    'override_system_checks'
]

# To simplify Django's test suite; not meant as a public API
try:
    from unittest import mock  # NOQA
except ImportError:
    try:
        import mock  # NOQA
    except ImportError:
        pass
+8 −1
Original line number Diff line number Diff line
@@ -24,6 +24,11 @@ Running the unit tests
Quickstart
~~~~~~~~~~

If you are on Python < 3.3, you'll first need to install a backport of the
``unittest.mock`` module that's available in Python 3.3+. See
:ref:`running-unit-tests-dependencies` for details on installing `mock`_ and
the other optional test dependencies.

Running the tests requires a Django settings module that defines the
databases to use. To make it easy to get started, Django provides and uses a
sample settings module that uses the SQLite database. To run the tests:
@@ -166,6 +171,7 @@ dependencies:
*  pytz_
*  setuptools_
*  memcached_, plus a :ref:`supported Python binding <memcached>`
*  mock_ (for Python < 3.3)
*  gettext_ (:ref:`gettext_on_windows`)
*  selenium_
*  sqlparse_
@@ -176,7 +182,7 @@ like so:

.. code-block:: bash

   $ pip install -r tests/requirements/py2.txt  # Python 3: py3.txt
   $ pip install -r tests/requirements/py3.txt  # Python 2: py2.txt

You can also install the database adapter(s) of your choice using
``oracle.txt``, ``mysql.txt``, or ``postgres.txt``.
@@ -198,6 +204,7 @@ associated tests will be skipped.
.. _pytz: https://pypi.python.org/pypi/pytz/
.. _setuptools: https://pypi.python.org/pypi/setuptools/
.. _memcached: http://memcached.org/
.. _mock: https://pypi.python.org/pypi/mock
.. _gettext: http://www.gnu.org/software/gettext/manual/gettext.html
.. _selenium: https://pypi.python.org/pypi/selenium
.. _sqlparse: https://pypi.python.org/pypi/sqlparse
+2 −0
Original line number Diff line number Diff line
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
+2 −0
Original line number Diff line number Diff line
bcrypt
docutils
# move to py2.txt when dropping Python 3.2
mock
numpy
Pillow
PyYAML
+10 −0
Original line number Diff line number Diff line
@@ -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]

Loading