pytest-djangoapp


Namepytest-djangoapp JSON
Version 1.2.0 PyPI version JSON
download
home_pagehttps://github.com/idlesign/pytest-djangoapp
SummaryNice pytest plugin to help you with Django pluggable application testing.
upload_time2023-05-19 12:17:25
maintainer
docs_urlNone
authorIgor `idle sign` Starikov
requires_python
licenseBSD 3-Clause License
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage
            pytest-djangoapp
================
https://github.com/idlesign/pytest-djangoapp

|release| |lic| |coverage|

.. |release| image:: https://img.shields.io/pypi/v/pytest-djangoapp.svg
    :target: https://pypi.python.org/pypi/pytest-djangoapp

.. |lic| image:: https://img.shields.io/pypi/l/pytest-djangoapp.svg
    :target: https://pypi.python.org/pypi/pytest-djangoapp

.. |coverage| image:: https://img.shields.io/coveralls/idlesign/pytest-djangoapp/master.svg
    :target: https://coveralls.io/r/idlesign/pytest-djangoapp


Description
-----------

*Nice pytest plugin to help you with Django pluggable application testing.*

This exposes some useful tools for Django applications developers to facilitate tests authoring, including:

* Settings overriding
* Template tags testing
* User creation
* Request object creation
* Management command calls
* Mailing
* Migrations
* Messages
* DB queries audit
* Live server & client UI testing
* etc.

Suitable for testing apps for Django 1.8+.


How to use
----------

Let's say you have classical tests placing (inside application directory):

.. code-block::

    package_dir
    |__ myapp
    |  |__ __init__.py
    |  |__ tests
    |  |  |__ __init__.py
    |  |  |__ conftest.py  <- Configure djangoapp here.
    |
    |__ setup.py


Add the following lines into `conftest.py` to configure `djangoapp` and start using it:

.. code-block:: python

    # conftest.py
    from pytest_djangoapp import configure_djangoapp_plugin

    pytest_plugins = configure_djangoapp_plugin()


Fixtures usage examples can be found in the documentation and the source code.


Testing an entire project
-------------------------

Despite the fact that `djangoapp` is primarily aimed to reusable
Django applications testing one can use it also to test a project (a set of apps).
For that, pass a dotted settings module path into `settings` argument:


.. code-block:: python

    pytest_plugins = configure_djangoapp_plugin(
        settings='myproject.settings.settings_testing',
        migrate=False,  # If you do not want to apply migrations.
    )



What about pytest-django
------------------------

`pytest-djangoapp` does not depend on `pytest-django`.

There are design decisions in `pytest-django` that might make it uncomfortable to work with.

1. It uses `setuptools` entrypoints feature for `pytest` plugin discovery. It's not a problem by itself,
   but all kinds of bootstrapping with side effects made by `pytest-django` just on startup,
   make the plugin a poor choice for cases of system-wide (i.e. not venv) installations.

2. Philosophy that next to no unit test should require DB access may be quite annoying.

3. Some fixtures (e.g. `django_assert_num_queries`) usability arouse questions.

Despite that `pytest-django` is nice, of course.


`pytest-djangoapp` fixtures allow the use of Django without marking all relevant tests as needing
a database, as is required by pytest-django which provides the ``django_db`` mark and db fixtures.

If you have `pytest-django` already installed, it can be disabled for projects
using `pytest-djangoapp` by adding the following lines into ``pytest.ini``:

.. code-block:: ini

    # pytest.ini
    [pytest]
    addopts = -p no:django


Documentation
-------------

http://pytest-djangoapp.readthedocs.org/



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/idlesign/pytest-djangoapp",
    "name": "pytest-djangoapp",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "",
    "author": "Igor `idle sign` Starikov",
    "author_email": "idlesign@yandex.ru",
    "download_url": "https://files.pythonhosted.org/packages/11/3a/1f7213a14f93b5aadf7a805d4a9e384ea7857b58fc467a409418441cc03a/pytest-djangoapp-1.2.0.tar.gz",
    "platform": null,
    "description": "pytest-djangoapp\n================\nhttps://github.com/idlesign/pytest-djangoapp\n\n|release| |lic| |coverage|\n\n.. |release| image:: https://img.shields.io/pypi/v/pytest-djangoapp.svg\n    :target: https://pypi.python.org/pypi/pytest-djangoapp\n\n.. |lic| image:: https://img.shields.io/pypi/l/pytest-djangoapp.svg\n    :target: https://pypi.python.org/pypi/pytest-djangoapp\n\n.. |coverage| image:: https://img.shields.io/coveralls/idlesign/pytest-djangoapp/master.svg\n    :target: https://coveralls.io/r/idlesign/pytest-djangoapp\n\n\nDescription\n-----------\n\n*Nice pytest plugin to help you with Django pluggable application testing.*\n\nThis exposes some useful tools for Django applications developers to facilitate tests authoring, including:\n\n* Settings overriding\n* Template tags testing\n* User creation\n* Request object creation\n* Management command calls\n* Mailing\n* Migrations\n* Messages\n* DB queries audit\n* Live server & client UI testing\n* etc.\n\nSuitable for testing apps for Django 1.8+.\n\n\nHow to use\n----------\n\nLet's say you have classical tests placing (inside application directory):\n\n.. code-block::\n\n    package_dir\n    |__ myapp\n    |  |__ __init__.py\n    |  |__ tests\n    |  |  |__ __init__.py\n    |  |  |__ conftest.py  <- Configure djangoapp here.\n    |\n    |__ setup.py\n\n\nAdd the following lines into `conftest.py` to configure `djangoapp` and start using it:\n\n.. code-block:: python\n\n    # conftest.py\n    from pytest_djangoapp import configure_djangoapp_plugin\n\n    pytest_plugins = configure_djangoapp_plugin()\n\n\nFixtures usage examples can be found in the documentation and the source code.\n\n\nTesting an entire project\n-------------------------\n\nDespite the fact that `djangoapp` is primarily aimed to reusable\nDjango applications testing one can use it also to test a project (a set of apps).\nFor that, pass a dotted settings module path into `settings` argument:\n\n\n.. code-block:: python\n\n    pytest_plugins = configure_djangoapp_plugin(\n        settings='myproject.settings.settings_testing',\n        migrate=False,  # If you do not want to apply migrations.\n    )\n\n\n\nWhat about pytest-django\n------------------------\n\n`pytest-djangoapp` does not depend on `pytest-django`.\n\nThere are design decisions in `pytest-django` that might make it uncomfortable to work with.\n\n1. It uses `setuptools` entrypoints feature for `pytest` plugin discovery. It's not a problem by itself,\n   but all kinds of bootstrapping with side effects made by `pytest-django` just on startup,\n   make the plugin a poor choice for cases of system-wide (i.e. not venv) installations.\n\n2. Philosophy that next to no unit test should require DB access may be quite annoying.\n\n3. Some fixtures (e.g. `django_assert_num_queries`) usability arouse questions.\n\nDespite that `pytest-django` is nice, of course.\n\n\n`pytest-djangoapp` fixtures allow the use of Django without marking all relevant tests as needing\na database, as is required by pytest-django which provides the ``django_db`` mark and db fixtures.\n\nIf you have `pytest-django` already installed, it can be disabled for projects\nusing `pytest-djangoapp` by adding the following lines into ``pytest.ini``:\n\n.. code-block:: ini\n\n    # pytest.ini\n    [pytest]\n    addopts = -p no:django\n\n\nDocumentation\n-------------\n\nhttp://pytest-djangoapp.readthedocs.org/\n\n\n",
    "bugtrack_url": null,
    "license": "BSD 3-Clause License",
    "summary": "Nice pytest plugin to help you with Django pluggable application testing.",
    "version": "1.2.0",
    "project_urls": {
        "Homepage": "https://github.com/idlesign/pytest-djangoapp"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "3c24a31cee815ad2fa8c150c3a61027ebda43506cc37880ab0a243ef4543eb2d",
                "md5": "e1234db52155d439403b97dcae4254d6",
                "sha256": "b35bb298f68c23848ad16f91c4577d403f3eacf5068dad6b49cec15b5ea724e0"
            },
            "downloads": -1,
            "filename": "pytest_djangoapp-1.2.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "e1234db52155d439403b97dcae4254d6",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 32360,
            "upload_time": "2023-05-19T12:17:23",
            "upload_time_iso_8601": "2023-05-19T12:17:23.191055Z",
            "url": "https://files.pythonhosted.org/packages/3c/24/a31cee815ad2fa8c150c3a61027ebda43506cc37880ab0a243ef4543eb2d/pytest_djangoapp-1.2.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "113a1f7213a14f93b5aadf7a805d4a9e384ea7857b58fc467a409418441cc03a",
                "md5": "ed8d8d5ccb3276a10698b5e3eef31a76",
                "sha256": "249706b88ac816c0f37306565556ce6f106ad1011bf5f28ba060df83d417376d"
            },
            "downloads": -1,
            "filename": "pytest-djangoapp-1.2.0.tar.gz",
            "has_sig": false,
            "md5_digest": "ed8d8d5ccb3276a10698b5e3eef31a76",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 32359,
            "upload_time": "2023-05-19T12:17:25",
            "upload_time_iso_8601": "2023-05-19T12:17:25.889975Z",
            "url": "https://files.pythonhosted.org/packages/11/3a/1f7213a14f93b5aadf7a805d4a9e384ea7857b58fc467a409418441cc03a/pytest-djangoapp-1.2.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-05-19 12:17:25",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "idlesign",
    "github_project": "pytest-djangoapp",
    "travis_ci": false,
    "coveralls": true,
    "github_actions": true,
    "tox": true,
    "lcname": "pytest-djangoapp"
}
        
Elapsed time: 0.16834s