How to use the behave.configuration.Configuration 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 kmmbvnr / django-jenkins / django_jenkins / tasks / behave_tests.py View on Github external
def __init__(self, features_dir):
            unittest.TestCase.__init__(self)
            self.features_dir = features_dir
            # sys.argv kludge
            # need to understand how to do this better
            # temporarily lose all the options etc
            # else behave will complain
            old_argv = sys.argv
            sys.argv = old_argv[:2]
            self.behave_config = behave.configuration.Configuration()
            sys.argv = old_argv
            # end of sys.argv kludge
            self.behave_config.paths = [features_dir]
            self.behave_config.format = ['pretty']

            self.behave_config.server_url = 'http://localhost:8081'

            # disable these in case you want to add set_trace in the tests you're developing
            self.behave_config.stdout_capture = False
            self.behave_config.stderr_capture = False
github JetBrains / teamcity-messages / tests / guinea-pigs / behave / _behave_runner.py View on Github external
if __name__ == "__main__":
    from behave.formatter import _registry
    from behave.configuration import Configuration
    from behave.runner import Runner
    from teamcity.jb_behave_formatter import TeamcityFormatter

    _registry.register_as("TeamcityFormatter", TeamcityFormatter)
    configuration = Configuration()
    configuration.format = ["TeamcityFormatter"]
    configuration.stdout_capture = False
    configuration.stderr_capture = False
    Runner(configuration).run()
github behave / behave / tests / unit / test_configuration.py View on Github external
def test_update_userdata__with_cmdline_defines(self):
        # -- NOTE: cmdline defines are reapplied.
        config = Configuration("-D person2=Bea", load_config=False)
        config.userdata = UserData(person1="AAA", person3="Charly")
        config.update_userdata(dict(person1="Alice", person2="Bob"))

        expected_data = dict(person1="Alice", person2="Bea", person3="Charly")
        assert config.userdata == expected_data
        assert config.userdata_defines == [("person2", "Bea")]
github behave / behave / tests / unit / test_configuration.py View on Github external
def test_cmdline_defines_without_value_are_true(self):
        config = Configuration("-D foo --define bar -Dbaz")
        assert "true" == config.userdata["foo"]
        assert "true" == config.userdata["bar"]
        assert "true" == config.userdata["baz"]
        assert True == config.userdata.getbool("foo")
github behave / behave / tests / unit / test_configuration.py View on Github external
def test_settings_without_stage(self):
        # -- OR: Setup with default, unnamed stage.
        self.ensure_stage_environment_is_not_set()
        assert "BEHAVE_STAGE" not in os.environ
        config = Configuration("")
        assert "steps" == config.steps_dir
        assert "environment.py" == config.environment_file
github behave / behave / tests / unit / test_configuration.py View on Github external
def test_cmdline_defines__with_quoted_name_value_pair(self):
        cmdlines = [
            '-D "person=Alice and Bob"',
            "-D 'person=Alice and Bob'",
        ]
        for cmdline in cmdlines:
            config = Configuration(cmdline, load_config=False)
            assert config.userdata == dict(person="Alice and Bob")
github behave / behave / tests / unit / test_configuration.py View on Github external
def test_cmdline_defines__with_quoted_value(self):
        cmdlines = [
            '-D person="Alice and Bob"',
            "-D person='Alice and Bob'",
        ]
        for cmdline in cmdlines:
            config = Configuration(cmdline, load_config=False)
            assert config.userdata == dict(person="Alice and Bob")
github allure-framework / allure-python / allure-behave / features / steps / behave_steps.py View on Github external
def run(context, **kwargs):
        cmd_args = '-f allure_behave.formatter:AllureFormatter'
        cmd = '{options} {cmd}'.format(cmd=cmd_args, options=kwargs.get('args', ''))
        config = Configuration(command_args=cmd)

        result_tmp_dir = mkdtemp(dir=os.environ.get('TEST_TMP', None))
        stream_opener = StreamOpener(filename=result_tmp_dir)

        model_runner = ModelRunner(config, [context.feature_definition])
        model_runner.formatters = make_formatters(config, [stream_opener])
        model_runner.formatters[0].listener.fixture_context.enter()
        model_runner.hooks = getattr(context, 'globals', dict())
        model_runner.run()

        model_runner.formatters[0].listener.__del__()
        context.allure_report = AllureReport(result_tmp_dir)
github django-behave / django-behave / django_behave / runner.py View on Github external
def setupBehave(self):
        # Create a sys.argv suitable for Behave to parse
        old_argv = sys.argv
        (sys.argv, our_opts) = parse_argv(old_argv, self.option_info)
        self.behave_config = Configuration()
        sys.argv = old_argv
        self.behave_config.browser = our_opts["browser"]

        self.behave_config.server_url = self.live_server_url  # property of LiveServerTestCase
        self.behave_config.paths = self.get_features_dir()
        self.behave_config.format = self.behave_config.format if self.behave_config.format else ['pretty']
        # disable these in case you want to add set_trace in the tests you're developing
        self.behave_config.stdout_capture = \
            self.behave_config.stdout_capture if self.behave_config.stdout_capture else False
        self.behave_config.stderr_capture = \
            self.behave_config.stderr_capture if self.behave_config.stderr_capture else False