Skip to content

Commit 6c23061

Browse files
committed
avoid importing gradio in tests because it spams warnings
1 parent 33446ac commit 6c23061

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

Diff for: test/conftest.py

+12-4
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,25 @@
11
import os
22

33
import pytest
4-
from PIL import Image
5-
from gradio.processing_utils import encode_pil_to_base64
4+
import base64
5+
66

77
test_files_path = os.path.dirname(__file__) + "/test_files"
88

99

10+
def file_to_base64(filename):
11+
with open(filename, "rb") as file:
12+
data = file.read()
13+
14+
base64_str = str(base64.b64encode(data), "utf-8")
15+
return "data:image/png;base64," + base64_str
16+
17+
1018
@pytest.fixture(scope="session") # session so we don't read this over and over
1119
def img2img_basic_image_base64() -> str:
12-
return encode_pil_to_base64(Image.open(os.path.join(test_files_path, "img2img_basic.png")))
20+
return file_to_base64(os.path.join(test_files_path, "img2img_basic.png"))
1321

1422

1523
@pytest.fixture(scope="session") # session so we don't read this over and over
1624
def mask_basic_image_base64() -> str:
17-
return encode_pil_to_base64(Image.open(os.path.join(test_files_path, "mask_basic.png")))
25+
return file_to_base64(os.path.join(test_files_path, "mask_basic.png"))

0 commit comments

Comments
 (0)