diff --git a/sigal/image.py b/sigal/image.py index bcf4bf2..d46ca71 100644 --- a/sigal/image.py +++ b/sigal/image.py @@ -36,6 +36,7 @@ import PIL import pilkit.processors import sys import warnings +import fractions from copy import deepcopy from datetime import datetime @@ -254,7 +255,8 @@ def get_exif_tags(data): exptime = data['ExposureTime'] if isinstance(exptime, tuple): try: - simple['exposure'] = exptime[0] / float(exptime[1]) + simple['exposure'] = str(fractions.Fraction(exptime[0], + exptime[1])) except IndexError: # Pillow == 3.0 simple['exposure'] = exptime[0] diff --git a/tests/conftest.py b/tests/conftest.py index 85c7b32..052eb6d 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- import os +import PIL import pytest from sigal.settings import read_settings @@ -12,3 +13,7 @@ CURRENT_DIR = os.path.abspath(os.path.dirname(__file__)) def settings(): """Read the sample config file.""" return read_settings(os.path.join(CURRENT_DIR, 'sample', 'sigal.conf.py')) + + +def pytest_report_header(config): + return "project deps: Pillow-{}".format(PIL.PILLOW_VERSION) diff --git a/tests/test_image.py b/tests/test_image.py index 224cb4f..df0cedc 100644 --- a/tests/test_image.py +++ b/tests/test_image.py @@ -1,6 +1,7 @@ # -*- coding:utf-8 -*- import os +import PIL import pytest from PIL import Image @@ -104,7 +105,10 @@ def test_get_exif_tags(): assert simple['iso'] == 50 assert simple['Make'] == 'NIKON' assert simple['datetime'] == 'Sunday, 22. January 2006' - assert simple['exposure'] == 0.00100603 + if PIL.PILLOW_VERSION == '3.0.0': + assert simple['exposure'] == 0.00100603 + else: + assert simple['exposure'] == '100603/100000000' data = {'FNumber': [1, 0], 'FocalLength': [1, 0], 'ExposureTime': 10} simple = get_exif_tags(data) @@ -142,7 +146,8 @@ def test_exif_copy(tmpdir): assert not simple -@pytest.mark.xfail +@pytest.mark.xfail(PIL.PILLOW_VERSION == '3.0.0', + reason="Pillow 3.0.0 was broken") def test_exif_gps(tmpdir): """Test reading out correct geo tags""" diff --git a/tox.ini b/tox.ini index 946bfe4..bfe256a 100644 --- a/tox.ini +++ b/tox.ini @@ -1,9 +1,11 @@ [tox] -envlist = py27,py33,py34,py35,report,check +envlist = py{27,33,34,35}-pillow{30,31},report,check [testenv] commands = py.test --cov sigal --cov-report term-missing deps = + pillow30: Pillow==3.0.0 + pillow31: Pillow>3.0.0 pytest pytest-capturelog pytest-cov