2018-02-16 23:36:52 +01:00
|
|
|
import blinker
|
2014-03-29 22:56:47 +01:00
|
|
|
import os
|
2016-01-08 00:11:17 +01:00
|
|
|
import PIL
|
2014-03-29 22:56:47 +01:00
|
|
|
import pytest
|
2016-02-01 00:41:34 +01:00
|
|
|
import shutil
|
2014-03-29 22:56:47 +01:00
|
|
|
|
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__))
|
2016-02-01 00:41:34 +01:00
|
|
|
BUILD_DIR = os.path.join(CURRENT_DIR, 'sample', '_build')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture(scope='session', autouse=True)
|
|
|
|
|
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."""
|
|
|
|
|
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):
|
|
|
|
|
if not name.startswith('_'):
|
|
|
|
|
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):
|
|
|
|
|
return "project deps: Pillow-{}".format(PIL.PILLOW_VERSION)
|