File: fixture_steps.py

package info (click to toggle)
behave 1.2.6-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 4,160 kB
  • sloc: python: 19,857; makefile: 137; sh: 18
file content (39 lines) | stat: -rw-r--r-- 1,336 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# -*- coding: UTF-8 -*-
# -- FILE: features/steps/fixture_steps.py

from __future__ import print_function
from behave import when
import os
import sys

# XXX
# # -- VARIANT 1:
# @when(u'I click on ${environment_variable:w}')
# def step_impl(context, environment_variable):
#       env_value = os.environ.get(environment_variable, None)
#       if env_value is None:
#            raise LookupError("Environment variable '%s' is undefined" % environment_variable)
#       print("USE ENVIRONMENT-VAR: %s = %s  (variant 1)" % (environment_variable, env_value))
#
#
# # -- VARIANT 2: Use type converter
# from behave import register_type
# import parse
#
# @parse.with_pattern(r"\$\w+")  # -- ONLY FOR: $WORD
# def parse_environment_var(text):
#     assert text.startswith("$")
#     env_name = text[1:]
#     env_value = os.environ.get(env_name, None)
#     return (env_name, env_value)
#
# register_type(EnvironmentVar=parse_environment_var)
#
# @when(u'I use the environment variable {environment_variable:EnvironmentVar}')
# def step_impl(context, environment_variable):
#       env_name, env_value = environment_variable
#       if env_value is None:
#            raise LookupError("Environment variable '%s' is undefined" % env_name)
#       print("USE ENVIRONMENT-VAR: %s = %s  (variant 2)" \
#             % (env_name, env_value))
#