'How to parse list of tuples with behave
How can I parse a list of tuples with behave? Tried looking at through the example here: https://behave.github.io/behave.example/datatype/cardinality_one_or_more.html but cannot figure it out. I originally tried using regex to locate the brackets but then figured there has to be a simpler built-in way of parsing a list of tuples
My scenario has this:
When I run the service "service" with input args [("21-01", "21-01")]
And the step function is
@when("I run the service {name} with input args {arg}")
def run_service(context, name, arg=None):
context.service_result = wrapper.wrappers[name](context.workset.getID(), arg)
However when the service is actually run, the input arg is always one big string rather than a list of tuples:
class service(InheritedClass):
def work(self, workset, *args):
print args
print args[0]
print args[0][0]
print type(args[0][0])
Where the output is
('[("21-01", "21-01")]',)
[("21-01", "21-01")]
[
<type 'str'>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
