... ructure that ships with Django for testing applications. See テストを書いて実行する for an explanation of how to write new tests. Running the unit tests Quickstart First, fork Django on GitHub . Second, create and activate a virtual environment. If yo ... miliar with how to do that, read our contributing tutorial . Next, clone your fork, install some requirements, and run the tests: / $ git clone https://github.com/YourGitHubName/django.git django-repo $ cd django-repo/tests $ python -m pip install ... -e .. $ python -m pip install -r requirements/py3.txt $ ./runtests.py ...\> git clone https://github.com/YourGitHubName/django.git django-repo ...\> cd django-repo\tests ...\> py -m pip ins ... ... conjunction, there is an emphasis on admin JavaScript performance and minimizing overall admin media file size. JavaScript tests Django's JavaScript tests can be run in a browser or from the command line. The tests are located in a top level js_tests ... directory. テストを書く Django's JavaScript tests use QUnit . Here is an example test module: QUnit . module ( 'magicTricks' , { beforeEach : function () { const $ = django ... onsult the QUnit documentation for information on the types of assertions supported by QUnit . テストの実行 The JavaScript tests may be run from a web browser or from the command line. Testing from a web browser To run the tests from a web browser, op ... ... ) Managing multiple versions of Python Python dependency management, including virtual environments The concept of running tests and building documentation If any of these are unfamiliar, see Djangoにはじめて貢献する for a longer, step-by-step tutoria ... vate If you are not using a Unix-like system, see the platform-specific instructions . Install the dependencies to run the tests and build the documentation: / $ python -m pip install -U pip $ python -m pip install -e . -r tests/requirements/py3.t ... xt -r docs/requirements.txt ...\> py -m pip install -U pip ...\> py -m pip install -e . -r tests\requirements\py3.txt -r docs\requirements.txt Install pre-commit hooks so that formatting and linting run automatically be ... ... or example, here's the typical lifecycle of a ticket: Alice creates a ticket and opens an incomplete pull request (missing tests, incorrect implementation). Bob reviews the pull request, marks the ticket as "Accepted", sets the flags "needs tests" and ... icket automatically into the "waiting on author" queue within the "accepted" stage. Alice updates the pull request, adding tests (but not yet fixing the implementation), and removes the two flags. The ticket moves into the "needs PR review" queue. Cha ... for people to review the supplied solution. This means downloading the patch and trying it out, verifying that it contains tests and docs, running the test suite with the included patch, and leaving feedback on the ticket. Waiting On Author (Accepted ... ... For backwards compatibility, this feature is disabled by default. See 持続的 (persistent) な接続 for details. Discovery of tests in any test module Django 1.6 ships with a new test runner that allows more flexibility in the location of tests. The prev ... ious runner ( django.test.simple.DjangoTestSuiteRunner ) found tests only in the models.py and tests.py modules of a Python package in INSTALLED_APPS . The new runner ... nto unittest2 (the version of unittest in the Python 2.7+ standard library, and bundled with Django). With test discovery, tests can be located in any module whose name matches the pattern test*.py . In addition, the test labels provided to ./manage.p ... ... This will help you build familiarity with the codebase and processes. Mark the appropriate flags if a patch needs docs or tests. Look through the changes a patch makes, and keep an eye out for syntax that is incompatible with older but still supporte ... d versions of Python. Run the tests and make sure they pass. Where possible and relevant, try them out on a database other than SQLite. Leave comments and fee ... トガンアプローチは、結局、良いことよりも悪いことの方が多いのです。 Be rigorous When we say " PEP 8 , and must have docs and tests", we mean it. If a patch doesn't have docs and tests, there had better be a good reason. Arguments like "I couldn't find a ... ... commit does. If you need to do additional work on your branch, commit as often as necessary: git commit -m 'Added two more tests for edge cases.' Publishing work You can publish your work on GitHub by running: git push origin ticket_xxxxx When you go ... d then paragraphs wrapped at 72 characters thereafter -- see the committing guidelines for more details, documentation and tests, if needed -- actually tests are always needed, except for documentation changes. The test suite must pass and the documen ... n the related Trac ticket explaining what you've done. In particular, you should note the environment in which you ran the tests, for instance: "all tests pass under SQLite and MySQL". Pull requests at GitHub have only two states: open and closed. The ... ... テストスイートを実行したことがない人は、事前に一度実行して出力に慣れておくと良いでしょう。 テストスイートを実行する前に、 cd tests コマンドを使って Django の tests/ ディレクトリに移動し、次を実行してテストの依存関係をインストールします: / $ python - ... 調べるか、発生したエラーメッセージをウェブで検索してください。 これでテストスイートを実行する準備が整いました: / $ ./runtests.py ...\> runtests.py さあ、座ってリラックスしてください。Django のテストスイート全体には何千ものテストがあり、コンピュータ ... テストは、テストを実行するために必要な外部ライブラリがインストールされていないことが原因です; 依存については Running all the tests を参照し、あなたの変更に関連するテストにする依存ライブラリがインストールしてください (このチュートリアルでは必要ありません ... ... のドキュメントを読んでください。 どこにテストを書くべき? デフォルトの startapp テンプレートは、新しいアプリケーション内に tests.py ファイルを作成します。テストの数が少ないうちは、ここに書くのがいいかもしれません。しかし、テストスイートが大きくなってき ... ./manage.py test Test discovery is based on the unittest module's built-in test discovery . By default, this will discover tests in any file named test*.py under the current working directory. ./manage.py test に好きな数の「テストラベル」を与えることで ... ase サブクラス、テストメソッドへのドット区切りの Python パスを指定します。たとえば、以下のように指定します。 # Run all the tests in the animals.tests module $ ./manage.py test animals.tests # Run all the tests found within the 'animals' package $ ./ma ... ... ins useful guidance on specific topics: How to submit a patch to Django for new and/or fixed behavior How to write and run tests How to run Django's unit tests How to work with Git and GitHub Related topics It's important to understand how we work and ... 2026年10月08日