Skip to content

Commit a807ede

Browse files
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>
1 parent ab14385 commit a807ede

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed

.changeset/vast-kings-deny.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"gradio": patch
3+
---
4+
5+
feat:Fix backend tests on Windows

gradio/components/file_explorer.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ def expand_braces(text, seen=None):
170170
def make_tree(files):
171171
tree = []
172172
for file in files:
173-
parts = file.split("/")
173+
parts = file.split(os.path.sep)
174174
make_node(parts, tree)
175175
return tree
176176

test/test_components.py

+8-6
Original file line numberDiff line numberDiff line change
@@ -2138,16 +2138,18 @@ def test_gallery(self):
21382138

21392139
postprocessed_gallery = gallery.postprocess(
21402140
[
2141-
("test/test_files/foo.png", "foo_caption"),
2141+
(str(Path("test/test_files/foo.png")), "foo_caption"),
21422142
(Path("test/test_files/bar.png"), "bar_caption"),
2143-
"test/test_files/baz.png",
2143+
str(Path("test/test_files/baz.png")),
21442144
Path("test/test_files/qux.png"),
21452145
]
21462146
).model_dump()
2147+
2148+
# Using str(Path(...)) to ensure that the test passes on all platforms
21472149
assert postprocessed_gallery == [
21482150
{
21492151
"image": {
2150-
"path": "test/test_files/foo.png",
2152+
"path": str(Path("test") / "test_files" / "foo.png"),
21512153
"orig_name": "foo.png",
21522154
"mime_type": None,
21532155
"size": None,
@@ -2157,7 +2159,7 @@ def test_gallery(self):
21572159
},
21582160
{
21592161
"image": {
2160-
"path": "test/test_files/bar.png",
2162+
"path": str(Path("test") / "test_files" / "bar.png"),
21612163
"orig_name": "bar.png",
21622164
"mime_type": None,
21632165
"size": None,
@@ -2167,7 +2169,7 @@ def test_gallery(self):
21672169
},
21682170
{
21692171
"image": {
2170-
"path": "test/test_files/baz.png",
2172+
"path": str(Path("test") / "test_files" / "baz.png"),
21712173
"orig_name": "baz.png",
21722174
"mime_type": None,
21732175
"size": None,
@@ -2177,7 +2179,7 @@ def test_gallery(self):
21772179
},
21782180
{
21792181
"image": {
2180-
"path": "test/test_files/qux.png",
2182+
"path": str(Path("test") / "test_files" / "qux.png"),
21812183
"orig_name": "qux.png",
21822184
"mime_type": None,
21832185
"size": None,

0 commit comments

Comments
 (0)