當前位置: 首頁>>代碼示例>>Python>>正文


Python configuration.Configuration類代碼示例

本文整理匯總了Python中behave.configuration.Configuration的典型用法代碼示例。如果您正苦於以下問題:Python Configuration類的具體用法?Python Configuration怎麽用?Python Configuration使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Configuration類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: handle

def handle(path):
    file_conf = ConfigObj(os.path.join(path, 'features', 'config.ini'))
    behave_options = file_conf['behave']['options']

    conf = Configuration(behave_options)
    conf.paths = [os.path.join(path, 'features')]
    runner = Runner(conf)
    runner.run()
開發者ID:Cito,項目名稱:zato-apitest,代碼行數:8,代碼來源:run.py

示例2: test_setup_userdata

    def test_setup_userdata(self):
        config = Configuration("", load_config=False)
        config.userdata = dict(person1="Alice", person2="Bob")
        config.userdata_defines = [("person2", "Charly")]
        config.setup_userdata()

        expected_data = dict(person1="Alice", person2="Charly")
        eq_(config.userdata, expected_data)
開發者ID:DisruptiveLabs,項目名稱:behave,代碼行數:8,代碼來源:test_configuration.py

示例3: test_update_userdata__without_cmdline_defines

    def test_update_userdata__without_cmdline_defines(self):
        config = Configuration("", load_config=False)
        config.userdata = UserData(person1="AAA", person3="Charly")
        config.update_userdata(dict(person1="Alice", person2="Bob"))

        expected_data = dict(person1="Alice", person2="Bob", person3="Charly")
        eq_(config.userdata, expected_data)
        self.assertFalse(config.userdata_defines)
開發者ID:DisruptiveLabs,項目名稱:behave,代碼行數:8,代碼來源:test_configuration.py

示例4: main

def main():
    config = Configuration()

    if config.version:
        print "behave " + __version__
        sys.exit(0)

    if config.tags_help:
        print TAG_HELP
        sys.exit(0)

    if config.lang_list:
        iso_codes = languages.keys()
        iso_codes.sort()
        print "Languages available:"
        for iso_code in iso_codes:
            native = languages[iso_code]['native'][0]
            name = languages[iso_code]['name'][0]
            print u'%s: %s / %s' % (iso_code, native, name)
        sys.exit(0)

    if config.lang_help:
        if config.lang_help not in languages:
            sys.exit('%s is not a recognised language: try --lang-list' %
                     config.lang_help)
        trans = languages[config.lang_help]
        print u"Translations for %s / %s" % (trans['name'][0],
              trans['native'][0])
        for kw in trans:
            if kw in 'name native'.split():
                continue
            print u'%16s: %s' % (kw.title().replace('_', ' '),
                  u', '.join(w for w in trans[kw] if w != '*'))
        sys.exit(0)

    if not config.format:
        format0 = config.defaults["format0"]
        config.format = [ format0 ]
    elif 'help' in config.format:
        print "Available formatters:"
        formatters.list_formatters(sys.stdout)
        sys.exit(0)
    # -- SANITY: Use at most one formatter, more cause various problems.
    # PROBLEM DESCRIPTION:
    #   1. APPEND MODE: configfile.format + --format
    #   2. Daisy chaining of formatter does not work
    #     => behave.formatter.formatters.get_formatter()
    #     => Stream methods, stream.write(), stream.flush are missing
    #        in Formatter interface
    if DISABLE_MULTI_FORMATTERS:
        config.format = config.format[-1:]

    runner = Runner(config)
    try:
        failed = runner.run()
    except ParserError, e:
        sys.exit(str(e))
開發者ID:jgr21,項目名稱:behave,代碼行數:57,代碼來源:__main__.py

示例5: test_update_userdata__with_cmdline_defines

    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")
        eq_(config.userdata, expected_data)
        eq_(config.userdata_defines, [("person2", "Bea")])
開發者ID:DisruptiveLabs,項目名稱:behave,代碼行數:9,代碼來源:test_configuration.py

示例6: main

def main():
    # pylint: disable=R0912,R0915
    #   R0912   Too many branches (17/12)
    #   R0915   Too many statements (57/50)
    config = Configuration()

    if config.version:
        print "behave " + __version__
        sys.exit(0)

    if config.tags_help:
        print TAG_HELP
        sys.exit(0)

    if config.lang_list:
        iso_codes = languages.keys()
        iso_codes.sort()
        print "Languages available:"
        for iso_code in iso_codes:
            native = languages[iso_code]["native"][0]
            name = languages[iso_code]["name"][0]
            print u"%s: %s / %s" % (iso_code, native, name)
        sys.exit(0)

    if config.lang_help:
        if config.lang_help not in languages:
            sys.exit("%s is not a recognised language: try --lang-list" % config.lang_help)
        trans = languages[config.lang_help]
        print u"Translations for %s / %s" % (trans["name"][0], trans["native"][0])
        for kw in trans:
            if kw in "name native".split():
                continue
            print u"%16s: %s" % (kw.title().replace("_", " "), u", ".join(w for w in trans[kw] if w != "*"))
        sys.exit(0)

    if not config.format:
        format0 = config.defaults["format0"]
        config.format = [format0]
    elif "help" in config.format:
        print "Available formatters:"
        formatters.list_formatters(sys.stdout)
        sys.exit(0)
    # -- SANITY: Use at most one formatter, more cause various problems.
    # PROBLEM DESCRIPTION:
    #   1. APPEND MODE: configfile.format + --format
    #   2. Daisy chaining of formatters does not work
    #     => behave.formatter.formatters.get_formatter()
    #     => Stream methods, stream.write(), stream.flush are missing
    #        in Formatter interface
    config.format = config.format[-1:]

    stream = config.output
    runner = Runner(config)
    try:
        failed = runner.run()
    except ParserError, e:
        sys.exit(str(e))
開發者ID:hangtwenty,項目名稱:behave,代碼行數:57,代碼來源:main.py

示例7: main

def main():
    config = Configuration()

    if config.version:
        print "behave " + __version__
        sys.exit(0)

    if config.tags_help:
        print TAG_HELP
        sys.exit(0)

    if config.lang_list:
        iso_codes = languages.keys()
        iso_codes.sort()
        print "Languages available:"
        for iso_code in iso_codes:
            native = languages[iso_code]["native"][0]
            name = languages[iso_code]["name"][0]
            print u"%s: %s / %s" % (iso_code, native, name)
        sys.exit(0)

    if config.lang_help:
        if config.lang_help not in languages:
            sys.exit("%s is not a recognised language: try --lang-list" % config.lang_help)
        trans = languages[config.lang_help]
        print u"Translations for %s / %s" % (trans["name"][0], trans["native"][0])
        for kw in trans:
            if kw in "name native".split():
                continue
            print u"%16s: %s" % (kw.title().replace("_", " "), u", ".join(w for w in trans[kw] if w != "*"))
        sys.exit(0)

    if not config.format:
        default_format = config.defaults["default_format"]
        config.format = [default_format]
    elif config.format and "format" in config.defaults:
        # -- CASE: Formatter are specified in behave configuration file.
        #    Check if formatter are provided on command-line, too.
        if len(config.format) == len(config.defaults["format"]):
            # -- NO FORMATTER on command-line: Add default formatter.
            default_format = config.defaults["default_format"]
            config.format.append(default_format)
    if "help" in config.format:
        print "Available formatters:"
        formatters.list_formatters(sys.stdout)
        sys.exit(0)

    if len(config.outputs) > len(config.format):
        print "CONFIG-ERROR: More outfiles (%d) than formatters (%d)." % (len(config.outputs), len(config.format))
        sys.exit(1)

    runner = Runner(config)
    try:
        failed = runner.run()
    except ParserError, e:
        sys.exit("ParseError: %s" % e)
開發者ID:vhumpa,項目名稱:behave,代碼行數:56,代碼來源:__main__.py

示例8: handle

def handle(path, args=None):
    file_conf = ConfigObj(os.path.join(path, "features", "config.ini"))
    try:
        behave_options = file_conf["behave"]["options"]
    except KeyError:
        raise ValueError("Behave config not found." " Are you running with the right path?")
    if args:
        behave_options += " " + " ".join(args)

    conf = Configuration(behave_options)
    conf.paths = [os.path.join(path, "features")]
    runner = Runner(conf)
    runner.run()
開發者ID:universsky,項目名稱:zato-apitest,代碼行數:13,代碼來源:run.py

示例9: handle

def handle(path, args=None):
    file_conf = ConfigObj(os.path.join(path, 'features', 'config.ini'))
    try:
        behave_options = file_conf['behave']['options']
    except KeyError:
        raise ValueError("Behave config not found."
            " Are you running with the right path?")
    if args:
        behave_options += ' ' + ' '.join(args)

    conf = Configuration(behave_options)
    conf.paths = [os.path.join(path, 'features')]
    runner = Runner(conf)
    return runner.run()
開發者ID:zatosource,項目名稱:zato-apitest,代碼行數:14,代碼來源:run.py

示例10: main

def main():
    config = Configuration()

    if config.version:
        print "behave " + __version__
        sys.exit(0)

    if config.tags_help:
        print TAG_HELP
        sys.exit(0)

    if config.lang_list:
        iso_codes = languages.keys()
        iso_codes.sort()
        print "Languages available:"
        for iso_code in iso_codes:
            native = languages[iso_code]['native'][0]
            name = languages[iso_code]['name'][0]
            print u'%s: %s / %s' % (iso_code, native, name)
        sys.exit(0)

    if config.lang_help:
        if config.lang_help not in languages:
            sys.exit('%s is not a recognised language: try --lang-list' %
                config.lang_help)
        trans = languages[config.lang_help]
        print u"Translations for %s / %s" % (trans['name'][0],
            trans['native'][0])
        for kw in trans:
            if kw in 'name native'.split():
                continue
            print u'%16s: %s' % (kw.title().replace('_', ' '),
                u', '.join(w for w in trans[kw] if w != '*'))
        sys.exit(0)

    if not config.format:
        config.format = ['pretty']
    elif 'help' in config.format:
        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))
開發者ID:eykd,項目名稱:behave,代碼行數:49,代碼來源:__main__.py

示例11: test_run_exclude_named_scenarios_with_regexp

    def test_run_exclude_named_scenarios_with_regexp(self):
        # -- NOTE: Works here only because it is run against Mocks.
        scenarios = [Mock(), Mock(), Mock()]
        scenarios[0].name = "Alice in Florida"
        scenarios[1].name = "Alice and Bob"
        scenarios[2].name = "Bob in Paris"
        scenarios[0].tags = []
        scenarios[1].tags = []
        scenarios[2].tags = []
        # -- FAKE-CHECK:
        scenarios[0].should_run_with_name_select.return_value = False
        scenarios[1].should_run_with_name_select.return_value = False
        scenarios[2].should_run_with_name_select.return_value = True

        for scenario in scenarios:
            scenario.run.return_value = False

        self.config.tags.check.return_value = True  # pylint: disable=no-member
        self.config.name = ["(?!Alice)"]    # Exclude all scenarios with "Alice"
        self.config.name_re = Configuration.build_name_re(self.config.name)

        feature = Feature('foo.feature', 1, u'Feature', u'foo',
                          scenarios=scenarios)

        feature.run(self.runner)

        assert not scenarios[0].run.called
        scenarios[0].should_run_with_name_select.assert_called_with(self.config)
        scenarios[1].should_run_with_name_select.assert_called_with(self.config)
        scenarios[2].should_run_with_name_select.assert_called_with(self.config)
        scenarios[0].run.assert_not_called()
        scenarios[1].run.assert_not_called()
        scenarios[2].run.assert_called_with(self.runner)
開發者ID:Abdoctor,項目名稱:behave,代碼行數:33,代碼來源:test_model.py

示例12: test_should_run_with_name_select

    def test_should_run_with_name_select(self):
        scenario_name = u"first scenario"
        scenario = Scenario("foo.feature", 17, u"Scenario", scenario_name)
        self.config.name = ['first .*', 'second .*']
        self.config.name_re = Configuration.build_name_re(self.config.name)

        assert scenario.should_run_with_name_select(self.config)
開發者ID:Abdoctor,項目名稱:behave,代碼行數:7,代碼來源:test_model.py

示例13: test_run_runs_named_scenarios

    def test_run_runs_named_scenarios(self):
        scenarios = [Mock(Scenario), Mock(Scenario)]
        scenarios[0].name = 'first scenario'
        scenarios[1].name = 'second scenario'
        scenarios[0].tags = []
        scenarios[1].tags = []
        # -- FAKE-CHECK:
        scenarios[0].should_run_with_name_select.return_value = True
        scenarios[1].should_run_with_name_select.return_value = False

        for scenario in scenarios:
            scenario.run.return_value = False

        self.config.tags.check.return_value = True  # pylint: disable=no-member
        self.config.name = ['first', 'third']
        self.config.name_re = Configuration.build_name_re(self.config.name)

        feature = Feature('foo.feature', 1, u'Feature', u'foo',
                          scenarios=scenarios)

        feature.run(self.runner)

        scenarios[0].run.assert_called_with(self.runner)
        assert not scenarios[1].run.called
        scenarios[0].should_run_with_name_select.assert_called_with(self.config)
        scenarios[1].should_run_with_name_select.assert_called_with(self.config)
開發者ID:Abdoctor,項目名稱:behave,代碼行數:26,代碼來源:test_model.py

示例14: test_run_runs_named_scenarios_with_regexp

    def test_run_runs_named_scenarios_with_regexp(self):
        scenarios = [Mock(), Mock()]
        scenarios[0].name = 'first scenario'
        scenarios[1].name = 'second scenario'
        scenarios[0].tags = []
        scenarios[1].tags = []
        # -- FAKE-CHECK:
        scenarios[0].should_run_with_name_select.return_value = False
        scenarios[1].should_run_with_name_select.return_value = True

        for scenario in scenarios:
            scenario.run.return_value = False

        self.config.tags.check.return_value = True
        self.config.name = ['third .*', 'second .*']
        self.config.name_re = Configuration.build_name_re(self.config.name)

        feature = model.Feature('foo.feature', 1, u'Feature', u'foo',
                                scenarios=scenarios)

        feature.run(self.runner)

        assert not scenarios[0].run.called
        scenarios[1].run.assert_called_with(self.runner)
        scenarios[0].should_run_with_name_select.assert_called_with(self.config)
        scenarios[1].should_run_with_name_select.assert_called_with(self.config)
開發者ID:masak,項目名稱:behave,代碼行數:26,代碼來源:test_model.py

示例15: test_run_runs_named_scenarios

    def test_run_runs_named_scenarios(self):
        scenarios = [Mock(Scenario), Mock(Scenario)]
        scenarios[0].name = "first scenario"
        scenarios[1].name = "second scenario"
        scenarios[0].tags = []
        scenarios[1].tags = []
        # -- FAKE-CHECK:
        scenarios[0].should_run_with_name_select.return_value = True
        scenarios[1].should_run_with_name_select.return_value = False

        for scenario in scenarios:
            scenario.run.return_value = False

        self.config.tag_expression.check.return_value = True  # pylint: disable=no-member
        self.config.name = ["first", "third"]
        self.config.name_re = Configuration.build_name_re(self.config.name)

        feature = Feature("foo.feature", 1, u"Feature", u"foo",
                          scenarios=scenarios)

        feature.run(self.runner)

        scenarios[0].run.assert_called_with(self.runner)
        assert not scenarios[1].run.called
        scenarios[0].should_run_with_name_select.assert_called_with(self.config)
        scenarios[1].should_run_with_name_select.assert_called_with(self.config)
開發者ID:behave,項目名稱:behave,代碼行數:26,代碼來源:test_model.py


注:本文中的behave.configuration.Configuration類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。