Refactor test fixtures.
This commit is contained in:
14
tests/conftest.py
Normal file
14
tests/conftest.py
Normal file
@@ -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'))
|
||||
@@ -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')
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user