-
Notifications
You must be signed in to change notification settings - Fork 1
Django notes
StephenChan edited this page Oct 9, 2012
·
10 revisions
This page is for notes about Django that are relevant to CoralNet development. This page isn't meant to be a re-wording of the entire Django documentation; its main purpose is to emphasize certain CoralNet-relevant points while offering some additional tips and links. However, in theory, a Django expert could skip this page entirely and just read the CoralNet documentation.
Basic resources for Django unit tests:
- Django docs - General info, how to write tests, how to run tests, Django-specific tools, Django-specific assert statements
- Python's unittest docs - info about Python unit tests (not specific to Django or web frameworks), general unit test assert statements
- Sample advice on what kind of functionality should be tested: 1 2
- Ensure that the Django MySQL user has all privileges on the test database. For more info, see the Setup page, under "Create a database and a user".
- By default, settings.DEBUG is set to False for unit tests, even if our settings file specifies it as True. Thus, if you haven't already done so, you should make sure your development copy can run the server with settings.DEBUG == False. This includes making sure static files are collected at settings.STATIC_ROOT; if this is not done, then running any test that uses the Test Client may result in static-file-related errors (such as
The system cannot find the path specified: u'css/master.css'
).
-
manage.py test
- Runs all tests of all apps in settings.INSTALLED_APPS, including third-party apps. Note that running third-party apps' tests is mainly only done to confirm compatibility and correct installation of these apps. In the normal workflow, it is typically only necessary to run tests for the apps we wrote.- Note: As of 2012 May 14, certain userena tests fail. This appears to be a problem in userena's test code instead of a problem related to CoralNet.
-
manage.py test [appname[.classname[.methodname]]]
- Runs only tests of a specific app, or a specific test class, or a specific test method. Examples:manage.py test images
,manage.py test images.ImageUploadTest
,manage.py test images.ImageUploadTest.test_image_upload_success
Also see "Running unit tests" in the CoralNet documentation.