mirror of
https://github.com/akuker/RASCSI.git
synced 2024-12-23 06:30:04 +00:00
Merge pull request #868 from nucleogenic/webui-pytest-warn-on-delete-failures
Display a warning when Pytest fixtures fail to delete a file
This commit is contained in:
commit
3ac3abb13f
@ -1,5 +1,6 @@
|
|||||||
import pytest
|
import pytest
|
||||||
import uuid
|
import uuid
|
||||||
|
import warnings
|
||||||
|
|
||||||
CFG_DIR = "/home/pi/.config/rascsi"
|
CFG_DIR = "/home/pi/.config/rascsi"
|
||||||
IMAGES_DIR = "/home/pi/images"
|
IMAGES_DIR = "/home/pi/images"
|
||||||
@ -37,7 +38,11 @@ def create_test_image(request, http_client):
|
|||||||
|
|
||||||
def delete():
|
def delete():
|
||||||
for image in images:
|
for image in images:
|
||||||
http_client.post("/files/delete", data={"file_name": image})
|
response = http_client.post("/files/delete", data={"file_name": image})
|
||||||
|
if response.status_code != 200 or response.json()["status"] != STATUS_SUCCESS:
|
||||||
|
warnings.warn(
|
||||||
|
f"Failed to auto-delete file created with create_test_image fixture: {image}"
|
||||||
|
)
|
||||||
|
|
||||||
request.addfinalizer(delete)
|
request.addfinalizer(delete)
|
||||||
return create
|
return create
|
||||||
@ -62,7 +67,9 @@ def list_attached_images(http_client):
|
|||||||
@pytest.fixture(scope="function")
|
@pytest.fixture(scope="function")
|
||||||
def delete_file(http_client):
|
def delete_file(http_client):
|
||||||
def delete(file_name):
|
def delete(file_name):
|
||||||
http_client.post("/files/delete", data={"file_name": file_name})
|
response = http_client.post("/files/delete", data={"file_name": file_name})
|
||||||
|
if response.status_code != 200 or response.json()["status"] != STATUS_SUCCESS:
|
||||||
|
warnings.warn(f"Failed to delete file via delete_file fixture: {file_name}")
|
||||||
|
|
||||||
return delete
|
return delete
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user