2014-03-29 22:56:47 +01:00
|
|
|
import os
|
2020-03-15 22:58:03 -03:00
|
|
|
import shutil
|
|
|
|
|
|
|
|
|
|
import blinker
|
2016-01-08 00:11:17 +01:00
|
|
|
import PIL
|
2014-03-29 22:56:47 +01:00
|
|
|
import pytest
|
|
|
|
|
|
2018-02-16 23:36:52 +01:00
|
|
|
from sigal import signals
|
2014-03-29 22:56:47 +01:00
|
|
|
from sigal.settings import read_settings
|
|
|
|
|
|
|
|
|
|
CURRENT_DIR = os.path.abspath(os.path.dirname(__file__))
|
2023-02-12 17:31:08 +01:00
|
|
|
BUILD_DIR = os.path.join(CURRENT_DIR, "sample", "_build")
|
2016-02-01 00:41:34 +01:00
|
|
|
|
|
|
|
|
|
2023-02-12 17:31:08 +01:00
|
|
|
@pytest.fixture(scope="session", autouse=True)
|
2016-02-01 00:41:34 +01:00
|
|
|
def remove_build():
|
|
|
|
|
"""Ensure that build directory does not exists before each test."""
|
|
|
|
|
if os.path.exists(BUILD_DIR):
|
|
|
|
|
shutil.rmtree(BUILD_DIR)
|
2014-03-29 22:56:47 +01:00
|
|
|
|
|
|
|
|
|
2015-04-20 00:05:07 +02:00
|
|
|
@pytest.fixture
|
2014-03-29 22:56:47 +01:00
|
|
|
def settings():
|
|
|
|
|
"""Read the sample config file."""
|
2023-02-12 17:31:08 +01:00
|
|
|
return read_settings(os.path.join(CURRENT_DIR, "sample", "sigal.conf.py"))
|
2016-01-08 00:11:17 +01:00
|
|
|
|
|
|
|
|
|
2018-02-16 23:36:52 +01:00
|
|
|
@pytest.fixture()
|
|
|
|
|
def disconnect_signals():
|
|
|
|
|
# Reset plugins
|
|
|
|
|
yield None
|
|
|
|
|
for name in dir(signals):
|
2023-02-12 17:31:08 +01:00
|
|
|
if not name.startswith("_"):
|
2018-02-16 23:36:52 +01:00
|
|
|
try:
|
|
|
|
|
sig = getattr(signals, name)
|
|
|
|
|
if isinstance(sig, blinker.Signal):
|
|
|
|
|
sig.receivers.clear()
|
|
|
|
|
except Exception:
|
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
2016-01-08 00:11:17 +01:00
|
|
|
def pytest_report_header(config):
|
2020-03-15 22:13:12 -03:00
|
|
|
return f"project deps: Pillow-{PIL.__version__}"
|