From 578636b194299d31e46c92d96452ccfc42a1075c Mon Sep 17 00:00:00 2001 From: Simon Conseil Date: Mon, 1 Feb 2016 00:41:34 +0100 Subject: [PATCH] Fix video filename for tests. The error was not detected is the _build was present. So this commit also removes the _build before each test. --- .travis.yml | 1 + tests/conftest.py | 9 +++++++++ tests/test_gallery.py | 24 ++++++++---------------- 3 files changed, 18 insertions(+), 16 deletions(-) diff --git a/.travis.yml b/.travis.yml index 31709e8..7610576 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,6 +14,7 @@ before_install: - sudo apt-get install -qq ubuntu-restricted-extras - sudo apt-get install -qq libfreetype6-dev libjpeg8-dev zlib1g-dev ffmpeg - sudo locale-gen fr_FR.UTF-8 + - ffmpeg -version install: - pip install -q Pillow==$PILLOW_VERSION - pip install pytest pytest-cov diff --git a/tests/conftest.py b/tests/conftest.py index 052eb6d..17e754d 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -3,10 +3,19 @@ import os import PIL import pytest +import shutil 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) @pytest.fixture diff --git a/tests/test_gallery.py b/tests/test_gallery.py index a48000d..c3096e0 100644 --- a/tests/test_gallery.py +++ b/tests/test_gallery.py @@ -66,7 +66,7 @@ REF = { 'thumbnail': ('video/thumbnails/' 'stallman software-freedom-day-low.tn.jpg'), 'subdirs': [], - 'medias': ['stallman software-freedom-day-low.webm'] + 'medias': ['stallman software-freedom-day-low.ogv'] } } @@ -151,27 +151,19 @@ def test_album(path, album, settings, tmpdir): assert a.name == album['name'] assert a.subdirs == album['subdirs'] assert a.thumbnail == album['thumbnail'] - assert [m.filename for m in a.medias] == album['medias'] + if path == 'video': + assert list(a.images) == [] + assert [m.filename for m in a.medias] == \ + [album['medias'][0].replace('.ogv', '.webm')] + else: + assert list(a.videos) == [] + assert [m.filename for m in a.medias] == album['medias'] assert len(a) == len(album['medias']) finally: # restore locale back locale.setlocale(locale.LC_ALL, old_locale) -def test_album_medias(settings): - gal = Gallery(settings, ncpu=1) - - album = REF['dir1/test1'] - a = Album('dir1/test1', settings, album['subdirs'], album['medias'], gal) - assert list(im.filename for im in a.images) == album['medias'] - assert list(a.videos) == [] - - album = REF['video'] - a = Album('video', settings, album['subdirs'], album['medias'], gal) - assert list(im.filename for im in a.videos) == album['medias'] - assert list(a.images) == [] - - def test_albums_sort(settings): gal = Gallery(settings, ncpu=1) album = REF['dir1']