Files
sigal/tests/conftest.py

45 lines
1.1 KiB
Python
Raw Normal View History

2014-03-29 22:56:47 +01:00
# -*- coding: utf-8 -*-
2018-02-16 23:36:52 +01:00
import blinker
2014-03-29 22:56:47 +01:00
import os
import PIL
2014-03-29 22:56:47 +01:00
import pytest
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__))
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
@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'))
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
def pytest_report_header(config):
return "project deps: Pillow-{}".format(PIL.PILLOW_VERSION)