'Setup env and start scan. Typically called from children\'s
test methods.
:param target: The target to scan.
:param plugins: PluginConfig objects to activate and setup before
the test runs.'

def _scan(self, target, plugins, debug=False, assert_exceptions=True, verify_targets=True):

    if (not isinstance(target, (basestring, tuple))):
        raise TypeError('Expected    basestring    or    tuple    in    scan    target.')
    if isinstance(target, tuple):
        target = tuple([URL(u) for u in target])
    elif isinstance(target, basestring):
        target = (URL(target),)
    if (verify_targets and (not self.MOCK_RESPONSES)):
        self._verify_targets_up(target)
    target_opts = create_target_option_list(*target)
    self.w3afcore.target.set_options(target_opts)
    for (ptype, plugincfgs) in plugins.items():
        self.w3afcore.plugins.set_plugins([p.name for p in plugincfgs], ptype)
        for pcfg in plugincfgs:
            if (pcfg.name == 'all'):
                continue
            plugin_instance = self.w3afcore.plugins.get_plugin_inst(ptype, pcfg.name)
            default_option_list = plugin_instance.get_options()
            unit_test_options = pcfg.options
            for option in default_option_list:
                if (option.get_name() not in unit_test_options):
                    unit_test_options.add(option)
            self.w3afcore.plugins.set_plugin_options(ptype, pcfg.name, unit_test_options)
    environ_debug = (os.environ.get('DEBUG', '0') == '1')
    if (debug or environ_debug):
        self._configure_debug()
    custom_test_agent = self.get_custom_agent()
    self.w3afcore.uri_opener.settings.set_user_agent(custom_test_agent)
    self.w3afcore.plugins.init_plugins()
    self.w3afcore.verify_environment()
    self.w3afcore.start()
    if assert_exceptions:
        caught_exceptions = self.w3afcore.exception_handler.get_all_exceptions()
        tracebacks = [e.get_details() for e in caught_exceptions]
        self.assertEqual(len(caught_exceptions), 0, tracebacks)
