# Path: mamba/runnable.py
# class ExecutionContext(object):
# class Runnable(object):
#     def __init__(self, parent=None, tags=None):
#     def execute(self, reporter, context, tags=None):
#     def has_tag(self, tag):
#     def included_in_execution(self, tags):
#     def failed(self):
#     def fail(self):


from mamba import runnable
from mamba.infrastructure import code_coverage


class BaseRunner(Runner):

    def __init__(self, example_collector, loader, reporter, tags):
        self.example_collector = example_collector
        self.loader = loader
        self.reporter = reporter
        self._has_failed_examples = False
        self.tags = tags

    def run(self):
        self.reporter.start()

        modules = self.example_collector.modules()

        if self._any_module_has_focused_examples(modules):
            self.tags = ['focus']

        for module in modules:
            self._run_examples_in(module)

        self.reporter.finish()

    def _any_module_has_focused_examples(self, modules):
        return any(getattr(module, '__mamba_has_focused_examples') for module in modules)

    def _run_examples_in(self, module):
        for example in self.loader.load_examples_from(module):
            example.execute(self.reporter,

# Path: mamba/runnable.py
# class ExecutionContext(object):
# class Runnable(object):
#     def __init__(self, parent=None, tags=None):
#     def execute(self, reporter, context, tags=None):
#     def has_tag(self, tag):
#     def included_in_execution(self, tags):
#     def failed(self):
#     def fail(self):


# Path: mamba/runners.py
from mamba import runnable
from mamba.infrastructure import code_coverage



class BaseRunner(Runner):

    def __init__(self, example_collector, loader, reporter, tags):
        self.example_collector = example_collector
        self.loader = loader
        self.reporter = reporter
        self._has_failed_examples = False
        self.tags = tags

    def run(self):
        self.reporter.start()

        modules = self.example_collector.modules()

        if self._any_module_has_focused_examples(modules):
            self.tags = ['focus']

        for module in modules:
            self._run_examples_in(module)

        self.reporter.finish()

    def _any_module_has_focused_examples(self, modules):
        return any(getattr(module, '__mamba_has_focused_examples') for module in modules)

    def _run_examples_in(self, module):
        for example in self.loader.load_examples_from(module):
            example.execute(self.reporter,

                            runnable.ExecutionContext(),