Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Add f string option to autocomplete feature #52

Open
Kellyyys opened this issue Jul 2, 2024 · 1 comment
Open

Add f string option to autocomplete feature #52

Kellyyys opened this issue Jul 2, 2024 · 1 comment

Comments

@Kellyyys
Copy link

Kellyyys commented Jul 2, 2024

Is your feature request related to a problem? Please describe.
When defining a behave step in python, we usually use f string to interpolate values. For example, we have:
@behave.given(f'the {regex} is set to "(.*?)"') However, the autocomplete could not search for the the regex that expressed as a f string. It only shows the options that use string like this : @behave.given("regex is reset")

Describe the solution you'd like
Autocomplete pop up should show the regex expressed as f string in implementation.

Additional context
I suggest the implementation of stepsParser.ts could be the following:
replace
const stepFileStepRe = new RegExp(${stepFileStepStartStr}u?(?:"|')(.+)(?:"|').*\\).*$, "i");
with
const stepFileStepRe = new RegExp(${stepFileStepStartStr}u?(?:"|f?')(.+)(?:"|').*\\).*$, "i");

@jimasp
Copy link
Owner

jimasp commented Aug 25, 2024

I'm confused by your request.
I've not seen an example of using an f-string as a behave step.
An f-string suggests you are modifying the string in the python code itself, rather than passing something in from the feature file.
Can you give an example of the full steps file and full feature file so I can see how this works?

Currently, parameters passed in from the feature file are supported without the "f":

@behave.given('the regex is set to "{value}"')
def a_step(context, value):
    assert context.regex == value

and a feature like this:

   Scenario: run a test 
      Given the regex is set to "(.*?)"
      When we implement a successful test
      Then we will see the result   

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants