diff --git a/tests/conftest.py b/tests/conftest.py new file mode 100644 index 0000000..c47a867 --- /dev/null +++ b/tests/conftest.py @@ -0,0 +1,14 @@ +# -*- coding: utf-8 -*- + +import os +import pytest + +from sigal.settings import read_settings + +CURRENT_DIR = os.path.abspath(os.path.dirname(__file__)) + + +@pytest.fixture(scope='session') +def settings(): + """Read the sample config file.""" + return read_settings(os.path.join(CURRENT_DIR, 'sample', 'sigal.conf.py')) diff --git a/tests/test_gallery.py b/tests/test_gallery.py index 20ea521..6aad7c4 100644 --- a/tests/test_gallery.py +++ b/tests/test_gallery.py @@ -6,10 +6,8 @@ import pytest from os.path import join from sigal.gallery import Album, Media, Image, Video, Gallery -from sigal.settings import read_settings CURRENT_DIR = os.path.dirname(__file__) -SAMPLE_DIR = os.path.join(CURRENT_DIR, 'sample') REF = { 'dir1': { @@ -54,19 +52,14 @@ REF = { 'video': { 'title': 'Video', 'name': 'video', - 'thumbnail': 'video/thumbnails/stallman software-freedom-day-low.tn.jpg', + 'thumbnail': ('video/thumbnails/' + 'stallman software-freedom-day-low.tn.jpg'), 'subdirs': [], 'medias': ['stallman software-freedom-day-low.ogv'] } } -@pytest.fixture(scope='module') -def settings(): - """Read the sample config file.""" - return read_settings(os.path.join(SAMPLE_DIR, 'sigal.conf.py')) - - def test_media(settings): m = Media('11.jpg', 'dir1/test1', settings) path = join('dir1', 'test1') diff --git a/tests/test_settings.py b/tests/test_settings.py index 63d0ecf..50e5d51 100644 --- a/tests/test_settings.py +++ b/tests/test_settings.py @@ -1,19 +1,12 @@ # -*- coding:utf-8 -*- import os -import pytest from sigal.settings import read_settings, get_thumb, get_orig CURRENT_DIR = os.path.abspath(os.path.dirname(__file__)) -@pytest.fixture(scope='module') -def settings(): - """Read the sample config file.""" - return read_settings(os.path.join(CURRENT_DIR, 'sample', 'sigal.conf.py')) - - def test_read_settings(settings): """Test that the settings are correctly read.""" assert settings['img_size'] == (640, 480)