Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
automatic1111
GitHub Repository: automatic1111/stable-diffusion-webui
Path: blob/master/test/conftest.py
3055 views
1
import base64
2
import os
3
4
import pytest
5
6
test_files_path = os.path.dirname(__file__) + "/test_files"
7
test_outputs_path = os.path.dirname(__file__) + "/test_outputs"
8
9
10
def pytest_configure(config):
11
# We don't want to fail on Py.test command line arguments being
12
# parsed by webui:
13
os.environ.setdefault("IGNORE_CMD_ARGS_ERRORS", "1")
14
15
16
def file_to_base64(filename):
17
with open(filename, "rb") as file:
18
data = file.read()
19
20
base64_str = str(base64.b64encode(data), "utf-8")
21
return "data:image/png;base64," + base64_str
22
23
24
@pytest.fixture(scope="session") # session so we don't read this over and over
25
def img2img_basic_image_base64() -> str:
26
return file_to_base64(os.path.join(test_files_path, "img2img_basic.png"))
27
28
29
@pytest.fixture(scope="session") # session so we don't read this over and over
30
def mask_basic_image_base64() -> str:
31
return file_to_base64(os.path.join(test_files_path, "mask_basic.png"))
32
33
34
@pytest.fixture(scope="session")
35
def initialize() -> None:
36
import webui # noqa: F401
37
38