Abid Ali Awan commited on
Commit
e29548e
·
1 Parent(s): 5922f7a

Refactor test assertions in test_app.py to validate string outputs instead of dicts, and utilize handle_file for local file paths.

Browse files
Files changed (1) hide show
  1. tests/test_app.py +9 -9
tests/test_app.py CHANGED
@@ -1,14 +1,14 @@
1
- from gradio_client import Client
2
 
3
  client = Client("http://127.0.0.1:7860/")
4
  result_1 = client.predict(
5
- local_file_path="data/test-document.pdf", output_format="docx", api_name="/predict"
6
  )
7
  print("Link to the document:", result_1)
8
  assert (
9
- isinstance(result_1, dict)
10
- and result_1.get("output_file") is not None
11
- and result_1.get("output_file").endswith(".docx")
12
  )
13
 
14
  result_2 = client.predict(
@@ -19,7 +19,7 @@ result_2 = client.predict(
19
 
20
  print("Link to the document:", result_2)
21
  assert (
22
- isinstance(result_2, dict)
23
- and result_2.get("output_file") is not None
24
- and result_2.get("output_file").endswith(".pdf")
25
- )
 
1
+ from gradio_client import Client, handle_file
2
 
3
  client = Client("http://127.0.0.1:7860/")
4
  result_1 = client.predict(
5
+ local_file_path=handle_file("data/test-document.pdf"), output_format="docx", api_name="/predict"
6
  )
7
  print("Link to the document:", result_1)
8
  assert (
9
+ isinstance(result_1, str)
10
+ and result_1 is not None # Check if the string itself is not None
11
+ and result_1.endswith(".docx")
12
  )
13
 
14
  result_2 = client.predict(
 
19
 
20
  print("Link to the document:", result_2)
21
  assert (
22
+ isinstance(result_2, str)
23
+ and result_2 is not None # Check if the string itself is not None
24
+ and result_2.endswith(".pdf")
25
+ )