範例 :: Playground

cd /tmp

virtualenv django-playground
source django-playground/bin/activate

pip install django django-debug-toolbar django-pdb pudb ipython ipdb coverage selenium mock

mkdir django-project
cd django-project
django-admin startproject mysite .

python manage.py runserver
# Now you can point web browser to localhost:8000

About urls.py

...
from . import views


...
    url(r'^$', views.index, name='index'),
    ...

About views.py

from django.http import HttpResponse


def index(request):
    return HttpResponse("Hello, world. You're at the polls index.")

About django-debug-toolbar

# settings.py
INSTALLED_APPS = (
    # ...
    'debug_toolbar',
)

About django-pdb

# settings.py
INSTALLED_APPS = (
    # ...
    'django_pdb',
)

MIDDLEWARE_CLASSES = (
    # ...
    'django_pdb.middleware.PdbMiddleware',
)

# point web browser to localhost:8000/?pdb

About pudb

About coverage

# .coveragerc (https://github.com/django/django/blob/master/tests/.coveragerc)
[run]
branch = True

# Usage
coverage run --source='.' manage.py test mysite
coverage report
coverage html

# point web browser to htmlconv/<source code>.html

About branch coverage analysis

results matching ""

    No results matching ""