How to use the behave.runner.Runner function in behave

To help you get started, we’ve selected a few behave examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github behave / behave / tests / unit / test_runner.py View on Github external
def test_setup_capture_creates_memory_handler_for_logging(self, handler):
        r = runner.Runner(Mock())
        r.config.stdout_capture = False
        r.config.log_capture = True
        r.context = Mock()

        r.setup_capture()

        assert r.capture_controller.log_capture is not None
        handler.assert_called_with(r.config)
        r.capture_controller.log_capture.inveigle.assert_called_with()
github behave / behave / tests / unit / test_runner.py View on Github external
def test_setup_capture_does_not_create_stringio_if_not_wanted(self):
        r = runner.Runner(Mock())
        r.config.stdout_capture = False
        r.config.stderr_capture = False
        r.config.log_capture = False

        r.setup_capture()

        assert r.capture_controller.stdout_capture is None
github behave / behave / tests / api / _test_async_step35.py View on Github external
from behave import given, when
            from behave.api.async_step import async_run_until_complete

            @given('an async-step passes')
            @async_run_until_complete
            async def given_async_step_passes(context):
                context.traced_steps.append("async-step1")

            @when('an async-step passes')
            @async_run_until_complete
            async def when_async_step_passes(context):
                context.traced_steps.append("async-step2")


        # -- RUN ASYNC-STEP: Verify that async-steps can be executed.
        context = Context(runner=Runner(config={}))
        context.traced_steps = []
        given_async_step_passes(context)
        when_async_step_passes(context)
        assert context.traced_steps == ["async-step1", "async-step2"]
github behave / behave / tests / unit / test_runner.py View on Github external
def test_supplied_feature_directory_missing(self):
        config = create_mock_config()
        config.paths = ["spam"]
        config.verbose = True
        r = runner.Runner(config)

        fs = FsMock()

        with patch("os.path", fs):
            with patch("os.walk", fs.walk):
                with pytest.raises(ConfigError):
                    r.setup_paths()
                # OLD: assert_raises(ConfigError, r.setup_paths)
github behave / behave / tests / api / _test_async_step34.py View on Github external
import asyncio

            @given('an async-step passes')
            @async_run_until_complete
            @asyncio.coroutine
            def given_async_step_passes(context):
                context.traced_steps.append("async-step1")

            @when('an async-step passes')
            @async_run_until_complete
            @asyncio.coroutine
            def when_async_step_passes(context):
                context.traced_steps.append("async-step2")

        # -- RUN ASYNC-STEP: Verify that async-steps can be execution without problems.
        context = Context(runner=Runner(config={}))
        context.traced_steps = []
        given_async_step_passes(context)
        when_async_step_passes(context)
        assert context.traced_steps == ["async-step1", "async-step2"]
github behave / behave / tests / unit / test_runner.py View on Github external
def test_supplied_root_directory(self):
        config = create_mock_config()
        config.paths = ["features"]
        config.verbose = True
        r = runner.Runner(config)

        fs = FsMock(
            "features/",
            "features/group1/",
            "features/group1/foo.feature",
            "features/steps/",
        )

        with patch("os.path", fs):
            with patch("os.walk", fs.walk):
                with r.path_manager:
                    r.setup_paths()

        # OLD: ok_(("isdir", os.path.join(fs.base, "features", "steps")) in fs.calls)
        assert ("isdir", os.path.join(fs.base, "features", "steps")) in fs.calls
        assert r.base_dir == os.path.join(fs.base, "features")
github behave / behave / behave / __main__.py View on Github external
# first failure.
        config.format = ['plain']
        config.stop = True
        config.log_capture = False
        config.stdou_capture = False

    if not config.format:
        config.format = ['pretty']
    elif config.format == ['help']:
        print "Available formatters:"
        formatters.list_formatters(sys.stdout)
        sys.exit(0)

    stream = config.output

    runner = Runner(config)
    try:
        failed = runner.run()
    except ParserError, e:
        sys.exit(str(e))
    except ConfigError, e:
        sys.exit(str(e))

    def format_summary(statement_type, summary):
        first = True
        parts = []
        for status in ('passed', 'failed', 'skipped', 'undefined'):
            if status not in summary:
                continue
            if first:
                label = statement_type
                if summary[status] != 1:
github behave / behave / behave / runner.py View on Github external
def __init__(self, config):
        super(Runner, self).__init__(config)
        self.path_manager = PathManager()
        self.base_dir = None