Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,18 @@ def before_scenario(context: PetStoreContext, scenario: Scenario):


def after_scenario(context: PetStoreContext, scenario: Scenario):
if scenario.status == "failed":
scenario_error_dir = Path("logs")
scenario_error_dir.mkdir(exist_ok=True)
base_name = time.strftime("%Y-%m-%d_%H%M%S_{}".format(re.sub(r'[/\\:*?"<>#]', "", scenario.name)[:60]))
log_file_path = scenario_error_dir / "{}.txt".format(base_name)
for step in scenario.steps:
if step.status in ["failed", "undefined"]:
log_file_path.write_text(
"Scenario: {}\nStep: {} {}\nError Message: {}".format(
scenario.name, step.keyword, step.name, step.error_message
)
)
break
else:
log_file_path.write_text("Scenario: {}\nStep: N/A".format(scenario.name))
if scenario.status != "failed":
return
scenario_error_dir = Path("logs")
scenario_error_dir.mkdir(exist_ok=True)
base_name = time.strftime("%Y-%m-%d_%H%M%S_{}".format(re.sub(r'[/\\:*?"<>#]', "", scenario.name)[:60]))
log_file_path = scenario_error_dir / f"{base_name}.txt"
for step in scenario.steps:
if step.status in ["failed", "undefined"]:
log_file_path.write_text(
f"Scenario: {scenario.name}\nStep: {step.keyword} {step.name}\nError Message: {step.error_message}"
)

break
else:
log_file_path.write_text(f"Scenario: {scenario.name}\nStep: N/A")
Comment on lines -33 to +47
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function after_scenario refactored with the following changes:

2 changes: 1 addition & 1 deletion petstore_swagger_bdd/browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def chrome_options():
if not gpu:
_chrome_options.add_argument("--disable-gpu")
if window_size:
_chrome_options.add_argument("--window-size={}".format(window_size))
_chrome_options.add_argument(f"--window-size={window_size}")
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function chrome_options refactored with the following changes:

if headless:
_chrome_options.add_argument("--headless")
_chrome_options.add_argument("--load-images=no")
Expand Down
4 changes: 2 additions & 2 deletions steps/petstore_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
def step_impl_1(context: PetStoreContext, method: str, status: str):
context.http_response = requests.request(
method=method,
url=context.base_url + "/v2/pet/findByStatus?status={}".format(status),
url=context.base_url + f"/v2/pet/findByStatus?status={status}",
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function step_impl_1 refactored with the following changes:

)


Expand All @@ -33,7 +33,7 @@ def step_impl_4(context: PetStoreContext, method: str):
raise ValueError("No value stored in context.pet_store_object.")
requests.request(
method=method,
url=context.base_url + "/v2/pet/{}".format(context.pet_store_object["id"]),
url=context.base_url + f'/v2/pet/{context.pet_store_object["id"]}',
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function step_impl_4 refactored with the following changes:

)


Expand Down