Open chris-morgan opened 12 years ago
Please note the examples with parameters as found here: http://lettuce.it/tutorial/simple.html#lettuce-b-define-steps-in-python
This behaviour is deliberate and required. If regex's were escaped automatically, it would not be possible to use parameters.
If you wish to match characters with special meaning, you should escape them yourself.
@SystemParadox, I think you've misunderstood the problem I'm reporting. I'm saying that the suggested code which will turn an undefined step into a failing step is incorrect, as it does not escape the step text. I'm saying it should be suggesting this:
@step(u'Given I have an \(undefined\) step')
def given_i_have_an_undefined_step(step):
assert False, 'This step must be implemented'
Oh sorry I see what you mean now.
I agree this would be a nice change to make.
@chris-morgan, as a point of clarification to help future readers, please could you change this sentence:
"However, this won't match the step because the magic characters haven't been escaped, so if you put in that code it will continue to fail"
to:
"However, this won't match the step because the magic characters haven't been escaped, so if you put in that code it will still be undefined"
Thanks.
If I start with a feature with regex magic characters in it:
It will suggest code like this:
However, this won't match the step because the magic characters haven't been escaped, so if you put in that code it will still be undefined (or succeed when it shouldn't if you had, for example,
.
or*
in the match).re.escape
should be brought to bear on the matter.