Skip to content

Commit

Permalink
Fix backend tests on Windows (#6781)
Browse files Browse the repository at this point in the history
* hotfix

* testing

* test

* fix

* fix

* add changeset

* add changeset

---------

Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
  • Loading branch information
abidlabs and gradio-pr-bot committed Dec 14, 2023
1 parent ab14385 commit a807ede
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
5 changes: 5 additions & 0 deletions .changeset/vast-kings-deny.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"gradio": patch
---

feat:Fix backend tests on Windows
2 changes: 1 addition & 1 deletion gradio/components/file_explorer.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ def expand_braces(text, seen=None):
def make_tree(files):
tree = []
for file in files:
parts = file.split("/")
parts = file.split(os.path.sep)
make_node(parts, tree)
return tree

Expand Down
14 changes: 8 additions & 6 deletions test/test_components.py
Original file line number Diff line number Diff line change
Expand Up @@ -2138,16 +2138,18 @@ def test_gallery(self):

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,
Expand All @@ -2157,7 +2159,7 @@ def test_gallery(self):
},
{
"image": {
"path": "test/test_files/bar.png",
"path": str(Path("test") / "test_files" / "bar.png"),
"orig_name": "bar.png",
"mime_type": None,
"size": None,
Expand All @@ -2167,7 +2169,7 @@ def test_gallery(self):
},
{
"image": {
"path": "test/test_files/baz.png",
"path": str(Path("test") / "test_files" / "baz.png"),
"orig_name": "baz.png",
"mime_type": None,
"size": None,
Expand All @@ -2177,7 +2179,7 @@ def test_gallery(self):
},
{
"image": {
"path": "test/test_files/qux.png",
"path": str(Path("test") / "test_files" / "qux.png"),
"orig_name": "qux.png",
"mime_type": None,
"size": None,
Expand Down

0 comments on commit a807ede

Please sign in to comment.