Example #1
0
from optparse import make_option
import sys

from django.core.management.commands import test

from django_pdb.management import load_parent_command
from django_pdb.testrunners import make_suite_runner


# Provide a Command class so that Django knows what will handle
# things. This module does not override it, so it just needs to find
# the parent Command.
Command = load_parent_command('test')


def patch_test_command(Command):
    """
    Monkeypatches Django's TestCommand so that it chooses to use
    ipdb or pdb, allowing subclasses to inherit from it and wrap its
    behaviour.
    """
    Command.option_list += type(Command.option_list)([
        make_option('--pdb', action='store_true', dest='pdb', default=False,
                    help='Drop into pdb shell on test errors or failures.'),
        make_option('--ipdb', action='store_true', dest='ipdb', default=False,
                    help='Drop into ipdb shell on test errors or failures.'),
    ])

    def handle(self, *test_labels, **options):
        """
        If --pdb is set on the command line ignore the default test runner
Example #2
0
from __future__ import print_function

import sys
import pdb

from django import VERSION as DJANGO_VERSION

from django_pdb.management import load_parent_command
from django_pdb.middleware import PdbMiddleware

from optparse import make_option
from django_pdb.utils import has_ipdb
from django.views import debug


RunServerCommand = load_parent_command('runserver')

extra_options = (
    ('--pdb',
     dict(action='store_true', dest='pdb', default=False,
          help='Drop into pdb shell on at the start of any view.')),
    ('--ipdb',
     dict(action='store_true', dest='ipdb', default=False,
          help='Drop into ipdb shell on at the start of any view.')),
    ('--pm',
     dict(action='store_true', dest='pm', default=False,
          help='Drop into ipdb shell if an exception is raised in a view.')),
)


class Command(RunServerCommand):
Example #3
0
import sys
import pudb as pdb

from django import VERSION as DJANGO_VERSION

from django_pdb.management import load_parent_command
from django_pdb.middleware import pudb as pdbMiddleware

from optparse import make_option
from django_pdb.utils import has_ipdb
from django.views import debug

RunServerCommand = load_parent_command('runserver')

extra_options = (
    ('--pdb',
     dict(action='store_true',
          dest='pdb',
          default=False,
          help='Drop into pdb shell on at the start of any view.')),
    ('--ipdb',
     dict(action='store_true',
          dest='ipdb',
          default=False,
          help='Drop into ipdb shell on at the start of any view.')),
    ('--pm',
     dict(action='store_true',
          dest='pm',
          default=False,
          help='Drop into ipdb shell if an exception is raised in a view.')),
)