Thanks all for the feedback.
1) I was trying to python a case to have a user to click a tab from the browser. There could be 2 scenarios: A) user has already login-in, and he may do the click directly. B) He may need to login himself first, then to click that tab. If it was the later case, I want to make a call to the login code which is defined somewhere else, by using this context.execute_steps() call.
2) So here is my code.
@given("make sure the user log-in")
def step_given_user_has_logged_in(context):
if context.holder.logged_in is True:
context.logger.info("user already login.")
return
else:
context.logger.info("user need to do login first.")
context.execute_steps(
"""
Given user is on the landing page
When he clicks the LOGIN button
And he provides the correct credential
And clicks the login button
Then he should be get into the extender main page
""".format(button="red")
)
context.holder.logged_in = True
return
this context.execute_steps() can be referenced from this link: https://behave.readthedocs.io/en/latest/api.html, and somehow when i do the pre-commit, it gives me such messages:
testcase.py:29: error: Not all arguments converted during string formatting
What I have just realized now is I may work around by calling in this way:
context.execute_steps(
"""
Given user is on the landing page
When he clicks the LOGIN button
And he provides the correct credential
And clicks the login button
Then he should be get into the extender main page
""")
It still works for me for user login, and it by-pass the pre-commit checking failure.
In my environment, I am using python 3.7, pre-commit version 1.2.0, and it was running on Ubuntu 16.0.4