本文整理汇总了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()
示例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)
示例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)
示例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))
示例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")])
示例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))
示例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)
示例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()
示例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()
示例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))
示例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)
示例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)
示例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)
示例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)
示例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)