GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing pytest-django.readthedocs.io — Getting started with pytest and pytest-django — pytest-django documentation Getting started with pytest and pytest-djangoIntroductionpytest and pytest-django are compatible with standard Django test suites and Nose test suites. They should be able to pick up and run existing tests without any or little configuration. This section describes how to get started quickly. Talks, articles and blog posts
For general information and tutorials on pytest, see the pytest tutorial page. Step 1: Installationpytest-django can be obtained directly from PyPI, and can be installed with
pip install pytest-django Installing pytest-django will also automatically install the latest version of
pytest. By default, pytest-django does not depend on Django. If you want to ensure your
Django version is compatible with the installed pytest-django version (lower
bound only), it’s recommended to add the pip install pytest-django[django] Step 2: Point pytest to your Django settingsYou need to tell pytest which Django settings should be used for test runs. The easiest way to achieve this is to create a pytest configuration file with this information. Create a file called [pytest] DJANGO_SETTINGS_MODULE = yourproject.settings Another options for people that use [tool.pytest.ini_options] DJANGO_SETTINGS_MODULE = "yourproject.settings" You can also specify your Django settings by setting the
Optionally, also add the following line to the python_files = tests.py test_*.py *_tests.py Step 3: Run your test suiteTests are invoked directly with the pytest Do you have problems with pytest not finding your code? See the FAQ I see an error saying “could not import myproject.settings”. Next stepsThe Usage and invocations section describes more ways to interact with your test suites. pytest-django also provides some Django helpers to make it easier to write Django tests. Consult the pytest documentation for more information on pytest itself. Stuck? Need help?No problem, see the FAQ on How can I use manage.py test with pytest-django? for information on how to get help. |
| You are visitor 01402605 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |