Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I'm not sure how testing a view is tricky.</p> <p>You just use the <a href="https://docs.djangoproject.com/en/dev/topics/testing/tools/#the-test-client" rel="nofollow noreferrer">test client</a>.</p> <p>Code coverage is easy. You reason how how a URL request maps to a code path and make the appropriate URL requests.</p> <p>You can, if you want, call the view functions "manually" by creating a Request object and examining the Response object, but this is too much work.</p> <p>If you have doubts about your code coverage, that's a good thing. It means you have code you can't easily map to a URL (which is all a user can ever see of a web application.) If you have code that doesn't map to a URL, you should probably either (a) delete the code or (b) refactor it into a separate module.</p> <p>We have lots of modules outside our view functions. Our view functions import these modules. We test these "outside the view function" modules with ordinary unittest.</p> <hr> <p>Here's a typical structure.</p> <pre><code>some_big_product/ |-- __init__.py |-- settings.py |-- urls.py |-- logging.ini |-- other_global_files.py |-- an_app_1/ | |-- __init__.py | |-- urls.py | |-- models.py | |-- views.py | |-- tests.py &lt;-- the generic Django testing | |-- app_specific_module.py | |-- app_specific_package/ | | |-- __init__.py | |-- test_app_specific_module.py &lt;-- unittest | |-- test_app_specific_package.py |-- generic_module.py |-- generic_package/ | |-- __init__.py |-- tests/ | |-- test_this.py | |-- test_that.py | |-- test_all.py &lt;-- not always practical |-- scripts/ |-- run_tests.sh </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload