Fix backend tests on Windows (#6781)

* hotfix

* testing

* test

* fix

* fix

* add changeset

* add changeset

---------

Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
This commit is contained in:
Abubakar Abid 2023-12-14 11:23:30 -08:00 committed by GitHub
parent ab143855a9
commit a807ede818
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 7 deletions

View File

@ -0,0 +1,5 @@
---
"gradio": patch
---
feat:Fix backend tests on Windows

View File

@ -170,7 +170,7 @@ class FileExplorer(Component):
def make_tree(files):
tree = []
for file in files:
parts = file.split("/")
parts = file.split(os.path.sep)
make_node(parts, tree)
return tree

View File

@ -2138,16 +2138,18 @@ class TestGallery:
postprocessed_gallery = gallery.postprocess(
[
("test/test_files/foo.png", "foo_caption"),
(str(Path("test/test_files/foo.png")), "foo_caption"),
(Path("test/test_files/bar.png"), "bar_caption"),
"test/test_files/baz.png",
str(Path("test/test_files/baz.png")),
Path("test/test_files/qux.png"),
]
).model_dump()
# Using str(Path(...)) to ensure that the test passes on all platforms
assert postprocessed_gallery == [
{
"image": {
"path": "test/test_files/foo.png",
"path": str(Path("test") / "test_files" / "foo.png"),
"orig_name": "foo.png",
"mime_type": None,
"size": None,
@ -2157,7 +2159,7 @@ class TestGallery:
},
{
"image": {
"path": "test/test_files/bar.png",
"path": str(Path("test") / "test_files" / "bar.png"),
"orig_name": "bar.png",
"mime_type": None,
"size": None,
@ -2167,7 +2169,7 @@ class TestGallery:
},
{
"image": {
"path": "test/test_files/baz.png",
"path": str(Path("test") / "test_files" / "baz.png"),
"orig_name": "baz.png",
"mime_type": None,
"size": None,
@ -2177,7 +2179,7 @@ class TestGallery:
},
{
"image": {
"path": "test/test_files/qux.png",
"path": str(Path("test") / "test_files" / "qux.png"),
"orig_name": "qux.png",
"mime_type": None,
"size": None,