conftest.py 1.0 KB

123456789101112131415161718192021222324252627282930313233343536
  1. import base64
  2. import os
  3. import pytest
  4. test_files_path = os.path.dirname(__file__) + "/test_files"
  5. test_outputs_path = os.path.dirname(__file__) + "/test_outputs"
  6. def pytest_configure(config):
  7. # We don't want to fail on Py.test command line arguments being
  8. # parsed by webui:
  9. os.environ.setdefault("IGNORE_CMD_ARGS_ERRORS", "1")
  10. def file_to_base64(filename):
  11. with open(filename, "rb") as file:
  12. data = file.read()
  13. base64_str = str(base64.b64encode(data), "utf-8")
  14. return "data:image/png;base64," + base64_str
  15. @pytest.fixture(scope="session") # session so we don't read this over and over
  16. def img2img_basic_image_base64() -> str:
  17. return file_to_base64(os.path.join(test_files_path, "img2img_basic.png"))
  18. @pytest.fixture(scope="session") # session so we don't read this over and over
  19. def mask_basic_image_base64() -> str:
  20. return file_to_base64(os.path.join(test_files_path, "mask_basic.png"))
  21. @pytest.fixture(scope="session")
  22. def initialize() -> None:
  23. import webui # noqa: F401