本文整理汇总了Python中behave.userdata.UserData.update方法的典型用法代码示例。如果您正苦于以下问题:Python UserData.update方法的具体用法?Python UserData.update怎么用?Python UserData.update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类behave.userdata.UserData
的用法示例。
在下文中一共展示了UserData.update方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Configuration
# 需要导入模块: from behave.userdata import UserData [as 别名]
# 或者: from behave.userdata.UserData import update [as 别名]
#.........这里部分代码省略.........
"""
# -- NOTE: re.LOCALE is removed in Python 3.6 (deprecated in Python 3.5)
# flags = (re.UNICODE | re.LOCALE)
pattern = u"|".join(names)
return re.compile(pattern, flags=re.UNICODE)
def exclude(self, filename):
if isinstance(filename, FileLocation):
filename = six.text_type(filename)
if self.include_re and self.include_re.search(filename) is None:
return True
if self.exclude_re and self.exclude_re.search(filename) is not None:
return True
return False
def setup_logging(self, level=None, configfile=None, **kwargs):
"""
Support simple setup of logging subsystem.
Ensures that the logging level is set.
But note that the logging setup can only occur once.
SETUP MODES:
* :func:`logging.config.fileConfig()`, if ``configfile`` is provided.
* :func:`logging.basicConfig()`, otherwise.
.. code-block: python
# -- FILE: features/environment.py
def before_all(context):
context.config.setup_logging()
:param level: Logging level of root logger.
If None, use :attr:`logging_level` value.
:param configfile: Configuration filename for fileConfig() setup.
:param kwargs: Passed to :func:`logging.basicConfig()`
"""
if level is None:
level = self.logging_level # pylint: disable=no-member
if configfile:
from logging.config import fileConfig
fileConfig(configfile)
else:
# pylint: disable=no-member
format_ = kwargs.pop("format", self.logging_format)
datefmt = kwargs.pop("datefmt", self.logging_datefmt)
logging.basicConfig(format=format_, datefmt=datefmt, **kwargs)
# -- ENSURE: Default log level is set
# (even if logging subsystem is already configured).
logging.getLogger().setLevel(level)
def setup_model(self):
if self.scenario_outline_annotation_schema:
name_schema = six.text_type(self.scenario_outline_annotation_schema)
ScenarioOutline.annotation_schema = name_schema.strip()
def setup_stage(self, stage=None):
"""Setup the test stage that selects a different set of
steps and environment implementations.
:param stage: Name of current test stage (as string or None).
EXAMPLE::
# -- SETUP DEFAULT TEST STAGE (unnamed):
config = Configuration()
config.setup_stage()
assert config.steps_dir == "steps"
assert config.environment_file == "environment.py"
# -- SETUP PRODUCT TEST STAGE:
config.setup_stage("product")
assert config.steps_dir == "product_steps"
assert config.environment_file == "product_environment.py"
"""
steps_dir = "steps"
environment_file = "environment.py"
if stage:
# -- USE A TEST STAGE: Select different set of implementations.
prefix = stage + "_"
steps_dir = prefix + steps_dir
environment_file = prefix + environment_file
self.steps_dir = steps_dir
self.environment_file = environment_file
def setup_userdata(self):
if not isinstance(self.userdata, UserData):
self.userdata = UserData(self.userdata)
if self.userdata_defines:
# -- ENSURE: Cmd-line overrides configuration file parameters.
self.userdata.update(self.userdata_defines)
def update_userdata(self, data):
"""Update userdata with data and reapply userdata defines (cmdline).
:param data: Provides (partial) userdata (as dict)
"""
self.userdata.update(data)
if self.userdata_defines:
# -- REAPPLY: Cmd-line defines (override configuration file data).
self.userdata.update(self.userdata_defines)