← Back to Django Course | Chapter 13: Testing in Django | Lesson 7 of 9

manage.py से Tests चलाना

python manage.py test वह single command है जो Django को बताता है कि आपके project में हर test ढूंढे और उन सभी को चलाए।
Syntax
markup
python manage.py test
python manage.py test app_name
python manage.py test app_name.tests.ClassName.test_name

पूरा Test Suite Run करना

सबसे simple invocation project के सभी apps के across हर discovered test चलाता है।

उदाहरण: Running the full test suite

The simplest invocation runs every discovered test across all apps in the project.

bash
python manage.py test

⚠️ Run this in your own terminal or Node.js environment.

एक App के लिए Tests Run करना

Command को एक single app के dotted path तक narrow करना उस app पर काम करते समय feedback loop तेज़ करता है।

उदाहरण: Running tests for one app

Narrowing the command to a single app's dotted path speeds up the feedback loop while working on that app.

bash
python manage.py test myapp

⚠️ Run this in your own terminal or Node.js environment.

एक Single Test Method Run करना

Method तक नीचे जाने वाला एक पूरी तरह dotted path आपको सिर्फ वह test फिर से चलाने देता है जिसे आप actively debug कर रहे हैं।

उदाहरण: Running a single test method

A fully dotted path down to the method lets you re-run just the test you're actively debugging.

bash
python manage.py test myapp.tests.BookModelTests.test_book_title_saved

⚠️ Run this in your own terminal or Node.js environment.

Related Topics
{# common_mistakes/chapter_summary/browser_support: on Hindi pages the view already swaps in the hi_ translation fields (or blanks these out if untranslated), so this renders correctly for both languages without a lang_code check here. #}
आम गलतियां
  1. गलती से असली development database के against tests चलाना — Django हमेशा अपने आप एक अलग test database बनाता है, इसलिए यह डर गलत है लेकिन beginners को confuse करता है जिन्हें यह पता नहीं होता।
  2. Debug करते समय test command को एक app तक narrow न करना, feedback loop को ज़रूरत से ज़्यादा slow बनाते हुए।
  3. Output में एक skipped या errored test को यह investigate करने के बजाय ignore करना कि यह क्यों नहीं चला।
चैप्टर सारांश
  • python manage.py test हर installed app में हर test discover करता है और चलाता है।
  • आप dotted paths के साथ एक specific app, class, या method target कर सकते हैं।
  • Command हर passing test के लिए एक dot और हर failure के लिए एक पूरा traceback print करता है।
  • आखिर में एक summary line report करती है कि कितने tests चले, और क्या वे सभी pass हुए।

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.