Beispiel #1
0
    def create_runner(self):
        settings = self.create_settings()
        runner = runners.BaseRunner(self.create_example_collector(), loader.Loader(settings.match_name), self.create_reporter())

        if settings.enable_code_coverage:
            runner = runners.CodeCoverageRunner(runner, settings.code_coverage_file)

        if settings.enable_file_watcher:
            runner = runners.FileWatcherRunner(runner)

        return runner
Beispiel #2
0
 def _loader(self):
     return loader.Loader()
        with it('loads module from absolute path'):
            module = _load_module(IRRELEVANT_PATH)

            expect(inspect.ismodule(module)).to(be_true)

        with it('loads module from relative path'):
            module = _load_module(spec_relpath('without_inner_contexts.py'))

            expect(inspect.ismodule(module)).to(be_true)

    #FIXME: Mixed responsabilities in test [collect, load]??
    with context('when loading'):
        with it('orders examples by line number'):
            module = _load_module(spec_abspath('without_inner_contexts.py'))

            examples = loader.Loader().load_examples_from(module)

            expect(examples).to(have_length(1))
            expect(example_names(examples[0].examples)).to(equal(['it first example', 'it second example', 'it third example']))

        with it('places examples together and groups at the end'):
            module = _load_module(spec_abspath('with_inner_contexts.py'))

            examples = loader.Loader().load_examples_from(module)

            expect(examples).to(have_length(1))
            expect(example_names(examples[0].examples)).to(equal(['it first example', 'it second example', 'it third example', '#inner_context']))

    with context('when reading tags'):
        with it('reads tags from description parameters'):
            module = _load_module(WITH_TAGS_PATH)
Beispiel #4
0
IMPORTED_CONTEXT_PATH = spec_abspath('with_exported_context/imported.py')
EXPORTED_INCLUDED_CONTEXT_PATH = spec_abspath(
    'with_exported/exported_included.py')
IMPORTED_EXPORTED_INCLUDED_CONTEXT_PATH = spec_abspath(
    'with_exported/imported_exported_included.py')


def _load_modules(paths):
    example_collector = ExampleCollector(paths)
    return list(example_collector.modules())


with context('when a exported context is loaded'):
    with it('mark context as exported'):
        module = _load_modules([EXPORTED_CONTEXT_PATH])[0]
        examples = loader.Loader().load_examples_from(module)
        expect(examples).to(have_length(1))
        expect(examples[0]).to(be_a(example_group.ExportedExampleGroup))

with description('including an exported_context') as self:
    with context('correctly ordered'):
        with before.each:
            self.modules = _load_modules(
                [EXPORTED_CONTEXT_PATH, IMPORTED_CONTEXT_PATH])
            self.examples = loader.Loader().load_examples_from(self.modules[1])

        with it('inserts a normal example group'):
            expect(self.examples[0]).to(have_length(1))
            expect(self.examples[0].examples[0]).to(
                be_a(example_group.ExampleGroup))