diff options
Diffstat (limited to 'docs/internals/contributing/writing-code')
4 files changed, 32 insertions, 35 deletions
diff --git a/docs/internals/contributing/writing-code/coding-style.txt b/docs/internals/contributing/writing-code/coding-style.txt index a699e39bd8..21146600b4 100644 --- a/docs/internals/contributing/writing-code/coding-style.txt +++ b/docs/internals/contributing/writing-code/coding-style.txt @@ -136,14 +136,17 @@ Model style * ``def get_absolute_url()`` * Any custom methods -* If ``choices`` is defined for a given model field, define the choices as - a tuple of tuples, with an all-uppercase name, either near the top of - the model module or just above the model class. Example:: +* If ``choices`` is defined for a given model field, define each choice as + a tuple of tuples, with an all-uppercase name as a class attribute on the + model. Example:: - DIRECTION_CHOICES = ( - ('U', 'Up'), - ('D', 'Down'), - ) + class MyModel(models.Model): + DIRECTION_UP = 'U' + DIRECTION_DOWN = 'D' + DIRECTION_CHOICES = ( + (DIRECTION_UP, 'Up'), + (DIRECTION_DOWN, 'Down'), + ) Use of ``django.conf.settings`` ------------------------------- @@ -177,9 +180,9 @@ That means that the ability for third parties to import the module at the top level is incompatible with the ability to configure the settings object manually, or makes it very difficult in some circumstances. -Instead of the above code, a level of laziness or indirection must be used, such -as :class:`django.utils.functional.LazyObject`, -:func:`django.utils.functional.lazy` or ``lambda``. +Instead of the above code, a level of laziness or indirection must be used, +such as ``django.utils.functional.LazyObject``, +``django.utils.functional.lazy()`` or ``lambda``. Miscellaneous ------------- diff --git a/docs/internals/contributing/writing-code/submitting-patches.txt b/docs/internals/contributing/writing-code/submitting-patches.txt index a90dc32605..ed8aad99b3 100644 --- a/docs/internals/contributing/writing-code/submitting-patches.txt +++ b/docs/internals/contributing/writing-code/submitting-patches.txt @@ -176,8 +176,10 @@ Compressing JavaScript ~~~~~~~~~~~~~~~~~~~~~~ To simplify the process of providing optimized javascript code, Django -includes a handy script which should be used to create a "minified" version. -This script is located at ``django/contrib/admin/static/admin/js/compress.py``. +includes a handy python script which should be used to create a "minified" +version. To run it:: + + python django/contrib/admin/bin/compress.py Behind the scenes, ``compress.py`` is a front-end for Google's `Closure Compiler`_ which is written in Java. However, the Closure Compiler diff --git a/docs/internals/contributing/writing-code/unit-tests.txt b/docs/internals/contributing/writing-code/unit-tests.txt index 4e702ff83e..f56bf1cdeb 100644 --- a/docs/internals/contributing/writing-code/unit-tests.txt +++ b/docs/internals/contributing/writing-code/unit-tests.txt @@ -7,16 +7,14 @@ code base. It's our policy to make sure all tests pass at all times. The tests cover: -* Models and the database API (``tests/modeltests``), -* Everything else in core Django code (``tests/regressiontests``), -* :ref:`contrib-apps` (``django/contrib/<app>/tests`` or - ``tests/regressiontests/<app>_...``). +* Models, the database API and everything else in core Django core (``tests/``), +* :ref:`contrib-apps` (``django/contrib/<app>/tests`` or ``tests/<app>_...``). We appreciate any and all contributions to the test suite! The Django tests all use the testing infrastructure that ships with Django for -testing applications. See :doc:`Testing Django applications </topics/testing>` -for an explanation of how to write new tests. +testing applications. See :doc:`Testing Django applications +</topics/testing/overview>` for an explanation of how to write new tests. .. _running-unit-tests: @@ -105,9 +103,9 @@ internationalization, type: ./runtests.py --settings=path.to.settings generic_relations i18n -How do you find out the names of individual tests? Look in -``tests/modeltests`` and ``tests/regressiontests`` — each directory name -there is the name of a test. Contrib app names are also valid test names. +How do you find out the names of individual tests? Look in ``tests/`` — each +directory name there is the name of a test. Contrib app names are also valid +test names. If you just want to run a particular class of tests, you can specify a list of paths to individual test classes. For example, to run the ``TranslationTests`` @@ -128,13 +126,13 @@ Running the Selenium tests Some admin tests require Selenium 2, Firefox and Python >= 2.6 to work via a real Web browser. To allow those tests to run and not be skipped, you must -install the selenium_ package (version > 2.13) into your Python path. - -Then, run the tests normally, for example: +install the selenium_ package (version > 2.13) into your Python path and run +the tests with the ``--selenium`` option: .. code-block:: bash - ./runtests.py --settings=test_sqlite admin_inlines + ./runtests.py --settings=test_sqlite --selenium admin_inlines + .. _running-unit-tests-dependencies: @@ -145,9 +143,6 @@ If you want to run the full suite of tests, you'll need to install a number of dependencies: * PyYAML_ -* Markdown_ -* Textile_ -* Docutils_ * setuptools_ * memcached_, plus a :ref:`supported Python binding <memcached>` * gettext_ (:ref:`gettext_on_windows`) @@ -160,9 +155,6 @@ Each of these dependencies is optional. If you're missing any of them, the associated tests will be skipped. .. _PyYAML: http://pyyaml.org/wiki/PyYAML -.. _Markdown: http://pypi.python.org/pypi/Markdown/1.7 -.. _Textile: http://pypi.python.org/pypi/textile -.. _docutils: http://pypi.python.org/pypi/docutils/0.4 .. _setuptools: http://pypi.python.org/pypi/setuptools/ .. _memcached: http://memcached.org/ .. _gettext: http://www.gnu.org/software/gettext/manual/gettext.html @@ -200,7 +192,7 @@ multiple modules by using a ``tests`` directory in the normal Python way. For the tests to be found, a ``models.py`` file must exist, even if it's empty. If you have URLs that need to be mapped, put them in ``tests/urls.py``. -To run tests for just one contrib app (e.g. ``markup``), use the same +To run tests for just one contrib app (e.g. ``auth``), use the same method as above:: - ./runtests.py --settings=settings markup + ./runtests.py --settings=settings auth diff --git a/docs/internals/contributing/writing-code/working-with-git.txt b/docs/internals/contributing/writing-code/working-with-git.txt index d4a95ae45a..dcfdd9e85b 100644 --- a/docs/internals/contributing/writing-code/working-with-git.txt +++ b/docs/internals/contributing/writing-code/working-with-git.txt @@ -81,7 +81,7 @@ commit them:: git commit When writing the commit message, follow the :ref:`commit message -guidelines <committing-guidlines>` to ease the work of the committer. If +guidelines <committing-guidelines>` to ease the work of the committer. If you're uncomfortable with English, try at least to describe precisely what the commit does. @@ -121,7 +121,7 @@ a pull request at GitHub. A good pull request means: * well-formed messages for each commit: a summary line and then paragraphs wrapped at 72 characters thereafter -- see the :ref:`committing guidelines - <committing-guidlines>` for more details, + <committing-guidelines>` for more details, * documentation and tests, if needed -- actually tests are always needed, except for documentation changes. |
