Debian Codegraph @

features/environment.py

raw ◀ ▶
Source reconstructed at patch state 0 of 1 — not the installed (fully patched) source.
1 Debian patch touch this file
1 # -*- coding: UTF-8 -*-
2
3 from behave.tag_matcher import ActiveTagMatcher, setup_active_tag_values
4 from behave4cmd0.setup_command_shell import setup_command_shell_processors4behave
5 import platform
6 import sys
7 import six
8
9 # -- MATCHES ANY TAGS: @use.with_{category}={value}
10 # NOTE: active_tag_value_provider provides category values for active tags.
11 python_version = "%s.%s" % sys.version_info[:2]
12 active_tag_value_provider = {
13 "python2": str(six.PY2).lower(),
14 "python3": str(six.PY3).lower(),
15 "python.version": python_version,
16 # -- python.implementation: cpython, pypy, jython, ironpython
17 "python.implementation": platform.python_implementation().lower(),
18 "pypy": str("__pypy__" in sys.modules).lower(),
19 "os": sys.platform,
20 }
21 active_tag_matcher = ActiveTagMatcher(active_tag_value_provider)
22
23 # -----------------------------------------------------------------------------
24 # HOOKS:
25 # -----------------------------------------------------------------------------
26 def before_all(context):
27 # -- SETUP ACTIVE-TAG MATCHER (with userdata):
28 # USE: behave -D browser=safari ...
29 setup_active_tag_values(active_tag_value_provider, context.config.userdata)
30 setup_python_path()
31 setup_context_with_global_params_test(context)
32 setup_command_shell_processors4behave()
33
34 def before_feature(context, feature):
35 if active_tag_matcher.should_exclude_with(feature.tags):
36 feature.skip(reason=active_tag_matcher.exclude_reason)
37
38 def before_scenario(context, scenario):
39 if active_tag_matcher.should_exclude_with(scenario.effective_tags):
40 scenario.skip(reason=active_tag_matcher.exclude_reason)
41
42 # -----------------------------------------------------------------------------
43 # SPECIFIC FUNCTIONALITY:
44 # -----------------------------------------------------------------------------
45 def setup_context_with_global_params_test(context):
46 context.global_name = "env:Alice"
47 context.global_age = 12
48
49 def setup_python_path():
50 # -- NEEDED-FOR: formatter.user_defined.feature
51 import os
52 PYTHONPATH = os.environ.get("PYTHONPATH", "")
53 os.environ["PYTHONPATH"] = "."+ os.pathsep + PYTHONPATH