mirror of
https://github.com/cookiecutter/cookiecutter-django.git
synced 2024-11-25 11:04:04 +03:00
EDITED the developing locally doc.
This commit is contained in:
parent
ed1c74ab12
commit
53940411cc
|
@ -29,7 +29,7 @@ First things first.
|
||||||
|
|
||||||
#. Create a new PostgreSQL database using createdb_: ::
|
#. Create a new PostgreSQL database using createdb_: ::
|
||||||
|
|
||||||
$ createdb <what you've entered as the project_slug at setup stage>
|
$ createdb <what you have entered as the project_slug at setup stage> -U postgres --password <password>
|
||||||
|
|
||||||
.. note::
|
.. note::
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@ Contents:
|
||||||
developing-locally-docker
|
developing-locally-docker
|
||||||
settings
|
settings
|
||||||
linters
|
linters
|
||||||
|
testing
|
||||||
deployment-on-pythonanywhere
|
deployment-on-pythonanywhere
|
||||||
deployment-on-heroku
|
deployment-on-heroku
|
||||||
deployment-with-docker
|
deployment-with-docker
|
||||||
|
|
56
docs/testing.rst
Normal file
56
docs/testing.rst
Normal file
|
@ -0,0 +1,56 @@
|
||||||
|
.. _testing:
|
||||||
|
|
||||||
|
Testing
|
||||||
|
========
|
||||||
|
|
||||||
|
We encourage users to build application tests. As best practice, this should be done immediately after documentation of the application being built, before starting on any coding.
|
||||||
|
|
||||||
|
Pytest
|
||||||
|
------
|
||||||
|
|
||||||
|
This project uses the Pytest_, a framework for easily building simple and scalable tests.
|
||||||
|
After you have set up to `develop locally`_, run the following commands to make sure the testing environment is ready: ::
|
||||||
|
|
||||||
|
$ pytest
|
||||||
|
|
||||||
|
You will get a readout of the `users` app that has already been set up with tests. If you do not want to run the `pytest` on the entire project, you can target a particular app by typing in its location: ::
|
||||||
|
|
||||||
|
$ pytest <path-to-app-in-project/app>
|
||||||
|
|
||||||
|
If you set up your project to `develop locally with docker`_, run the following command: ::
|
||||||
|
|
||||||
|
$ docker-compose -f local.yml run django pytest
|
||||||
|
|
||||||
|
Targetting particular apps for testing in ``docker`` follows a similar pattern as previously shown above.
|
||||||
|
|
||||||
|
Coverage
|
||||||
|
--------
|
||||||
|
|
||||||
|
You should build your tests to provide the highest level of **code coverage**. You can run the ``pytest`` with code ``coverage`` by typing in the following command: ::
|
||||||
|
|
||||||
|
$ docker-compose -f local.yml run django coverage run -m pytest
|
||||||
|
|
||||||
|
Once the tests are complete, in order to see the code coverage, run the following command: ::
|
||||||
|
|
||||||
|
$ docker-compose -f local.yml run django coverage report
|
||||||
|
|
||||||
|
.. note::
|
||||||
|
|
||||||
|
At the root of the project folder, you will find the `pytest.ini` file. You can use this to customize_ the ``pytest`` to your liking.
|
||||||
|
|
||||||
|
There is also the `.coveragerc`. This is the configuration file for the ``coverage`` tool. You can find out more about `configuring`_ ``coverage``.
|
||||||
|
|
||||||
|
.. seealso::
|
||||||
|
|
||||||
|
For unit tests, run: ::
|
||||||
|
|
||||||
|
$ python manage.py test
|
||||||
|
|
||||||
|
Since this is a fresh install, and there are no tests built using the Python `unittest`_ library yet, you should get feedback that says there were no tests carried out.
|
||||||
|
|
||||||
|
.. _Pytest: https://docs.pytest.org/en/latest/example/simple.html
|
||||||
|
.. _develop locally: ../developing-locally.rst
|
||||||
|
.. _develop locally with docker: ..../developing-locally-docker.rst
|
||||||
|
.. _customize: https://docs.pytest.org/en/latest/customize.html
|
||||||
|
.. _unittest: https://docs.python.org/3/library/unittest.html#module-unittest
|
||||||
|
.. _configuring: https://coverage.readthedocs.io/en/v4.5.x/config.html
|
Loading…
Reference in New Issue
Block a user