2024-05-26 15:58:33 +01:00
|
|
|
import os
|
|
|
|
|
|
2025-07-14 13:05:17 +02:00
|
|
|
|
2024-05-26 15:58:33 +01:00
|
|
|
def before_all(context):
|
|
|
|
|
context.endpoint = None
|
|
|
|
|
context.request_data = None
|
|
|
|
|
context.files = {}
|
|
|
|
|
context.response = None
|
|
|
|
|
|
2025-07-14 13:05:17 +02:00
|
|
|
|
2024-05-26 15:58:33 +01:00
|
|
|
def after_scenario(context, scenario):
|
2025-07-14 13:05:17 +02:00
|
|
|
if hasattr(context, "files"):
|
2024-05-26 15:58:33 +01:00
|
|
|
for file in context.files.values():
|
|
|
|
|
file.close()
|
2025-07-14 13:05:17 +02:00
|
|
|
if os.path.exists("response_file"):
|
|
|
|
|
os.remove("response_file")
|
|
|
|
|
if hasattr(context, "file_name") and os.path.exists(context.file_name):
|
2024-05-26 15:58:33 +01:00
|
|
|
os.remove(context.file_name)
|
2024-07-20 09:53:58 +01:00
|
|
|
|
|
|
|
|
# Remove any temporary files
|
2025-07-14 13:05:17 +02:00
|
|
|
for temp_file in os.listdir("."):
|
|
|
|
|
if temp_file.startswith("genericNonCustomisableName") or temp_file.startswith(
|
|
|
|
|
"temp_image_"
|
|
|
|
|
):
|
2025-01-11 22:06:46 +01:00
|
|
|
os.remove(temp_file)
|