mirror of
https://github.com/gradio-app/gradio.git
synced 2025-04-06 12:30:29 +08:00
9484-fix-windows-filepath-unit-tests (#10089)
* 9484-fix-windows-filepath-unit-tests * lint * consistent * changes * use pathlib * changes --------- Co-authored-by: Yuval Jacobson <yuvalj@liveu.tv> Co-authored-by: Abubakar Abid <abubakar@huggingface.co>
This commit is contained in:
parent
5ea3cb51a3
commit
b0f3f3a2a2
@ -1,3 +1,4 @@
|
||||
from pathlib import Path
|
||||
from typing import cast
|
||||
|
||||
import numpy as np
|
||||
@ -62,7 +63,7 @@ class TestImage:
|
||||
assert image_input.preprocess(img) is not None
|
||||
image_input.preprocess(img)
|
||||
file_image = gr.Image(type="filepath", image_mode=None)
|
||||
assert img.path == file_image.preprocess(img)
|
||||
assert Path(img.path).name == Path(str(file_image.preprocess(img))).name # type: ignore
|
||||
with pytest.raises(ValueError):
|
||||
gr.Image(type="unknown") # type: ignore
|
||||
|
||||
|
@ -373,8 +373,15 @@ def test_is_in_or_equal():
|
||||
assert not is_in_or_equal("/home/usr/subdirectory", "/home/usr/notes.txt")
|
||||
assert not is_in_or_equal("/home/usr/../../etc/notes.txt", "/home/usr/")
|
||||
assert not is_in_or_equal("/safe_dir/subdir/../../unsafe_file.txt", "/safe_dir/")
|
||||
assert is_in_or_equal("//foo/asd/", "/foo")
|
||||
|
||||
|
||||
@pytest.mark.skipif(
|
||||
sys.platform.startswith("win"),
|
||||
reason="Windows doesn't support POSIX double-slash notation",
|
||||
)
|
||||
def test_is_in_or_equal_posix_specific_paths():
|
||||
assert is_in_or_equal("//foo/..a", "//foo")
|
||||
assert is_in_or_equal("//foo/asd/", "/foo")
|
||||
assert is_in_or_equal("//foo/..²", "/foo")
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user