Reuse the disconnect_signals fixture
This commit is contained in:
@@ -1,10 +1,12 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import blinker
|
||||
import os
|
||||
import PIL
|
||||
import pytest
|
||||
import shutil
|
||||
|
||||
from sigal import signals
|
||||
from sigal.settings import read_settings
|
||||
|
||||
CURRENT_DIR = os.path.abspath(os.path.dirname(__file__))
|
||||
@@ -24,5 +26,19 @@ def settings():
|
||||
return read_settings(os.path.join(CURRENT_DIR, 'sample', 'sigal.conf.py'))
|
||||
|
||||
|
||||
@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)
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import blinker
|
||||
import io
|
||||
import logging
|
||||
import os
|
||||
from click.testing import CliRunner
|
||||
from os.path import join
|
||||
|
||||
from sigal import init, build, serve, set_meta, signals
|
||||
from sigal import init, build, serve, set_meta
|
||||
|
||||
TESTGAL = join(os.path.abspath(os.path.dirname(__file__)), 'sample')
|
||||
|
||||
@@ -26,7 +25,7 @@ def test_init(tmpdir):
|
||||
"keep it safe.\n")
|
||||
|
||||
|
||||
def test_build(tmpdir):
|
||||
def test_build(tmpdir, disconnect_signals):
|
||||
runner = CliRunner()
|
||||
config_file = str(tmpdir.join('sigal.conf.py'))
|
||||
tmpdir.mkdir('pictures')
|
||||
@@ -90,15 +89,6 @@ atom_feed = {'feed_url': 'http://example.org/feed.atom', 'nb_items': 10}
|
||||
logger = logging.getLogger('sigal')
|
||||
logger.handlers[:] = []
|
||||
logger.setLevel(logging.INFO)
|
||||
# Reset plugins
|
||||
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 test_serve(tmpdir):
|
||||
|
||||
@@ -1,30 +1,15 @@
|
||||
# -*- coding:utf-8 -*-
|
||||
|
||||
import os
|
||||
|
||||
import blinker
|
||||
import pytest
|
||||
|
||||
from sigal import init_plugins, signals
|
||||
from sigal import init_plugins
|
||||
from sigal.gallery import Gallery
|
||||
from sigal.plugins import compress_assets
|
||||
|
||||
CURRENT_DIR = os.path.dirname(__file__)
|
||||
|
||||
|
||||
@pytest.fixture(autouse=True)
|
||||
def disconnect_signals():
|
||||
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 make_gallery(settings, tmpdir, method):
|
||||
settings['destination'] = str(tmpdir)
|
||||
if "sigal.plugins.compress_assets" not in settings["plugins"]:
|
||||
@@ -48,7 +33,8 @@ def make_gallery(settings, tmpdir, method):
|
||||
[('gzip', 'gz', None),
|
||||
('zopfli', 'gz', 'zopfli.gzip'),
|
||||
('brotli', 'br', 'brotli')])
|
||||
def test_compress(settings, tmpdir, method, compress_suffix, test_import):
|
||||
def test_compress(disconnect_signals, settings, tmpdir, method,
|
||||
compress_suffix, test_import):
|
||||
if test_import:
|
||||
pytest.importorskip(test_import)
|
||||
compress_options = make_gallery(settings, tmpdir, method)
|
||||
|
||||
@@ -1,15 +1,14 @@
|
||||
# -*- coding:utf-8 -*-
|
||||
|
||||
import blinker
|
||||
import os
|
||||
|
||||
from sigal.gallery import Gallery
|
||||
from sigal import init_plugins, signals
|
||||
from sigal import init_plugins
|
||||
|
||||
CURRENT_DIR = os.path.dirname(__file__)
|
||||
|
||||
|
||||
def test_plugins(settings, tmpdir):
|
||||
def test_plugins(settings, tmpdir, disconnect_signals):
|
||||
|
||||
settings['destination'] = str(tmpdir)
|
||||
if "sigal.plugins.nomedia" not in settings["plugins"]:
|
||||
@@ -17,20 +16,9 @@ def test_plugins(settings, tmpdir):
|
||||
if "sigal.plugins.media_page" not in settings["plugins"]:
|
||||
settings['plugins'] += ["sigal.plugins.media_page"]
|
||||
|
||||
try:
|
||||
init_plugins(settings)
|
||||
gal = Gallery(settings)
|
||||
gal.build()
|
||||
finally:
|
||||
# Reset plugins
|
||||
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
|
||||
init_plugins(settings)
|
||||
gal = Gallery(settings)
|
||||
gal.build()
|
||||
|
||||
out_html = os.path.join(settings['destination'],
|
||||
'dir2', 'exo20101028-b-full.jpg.html')
|
||||
|
||||
Reference in New Issue
Block a user