Commits

Mikhail Korobov  committed 0cdc172

simple tests for image dimensions

  • Participants
  • Parent commits 4a09b3c

Comments (0)

Files changed (6)

 ^build
 \.ipynb$
 ^dist
-^psd_tools.egg-info
+^psd_tools.egg-info
+^\.coverage$
+; this is a tox config for running "psd-reader.py" script
+; under different Python interpreters
+
+[tox]
+envlist = py26,py27,py32,py33,pypy
+
+[testenv]
+
+; there are extra deps in order to reuse test tox virtualenvs
+; and not recreate them
+deps=
+    docopt >= 0.5
+    pytest
+    pytest-cov
+    coverage
+
+commands=
+    psd-tools.py []

File tests/__init__.py

+# -*- coding: utf-8 -*-
+from __future__ import absolute_import

File tests/test_dimensions.py

+# -*- coding: utf-8 -*-
+from __future__ import absolute_import, unicode_literals
+import pytest
+
+from .utils import load_psd
+
+DIMENSIONS = (
+    ('1layer.psd',              (101, 55)),
+    ('2layers.psd',             (101, 55)),
+    ('32bit.psd',               (100, 150)),
+    ('300dpi.psd',              (100, 150)),
+    ('clipping-mask.psd',       (360, 200)),
+    ('gradient fill.psd',       (100, 150)),
+    ('group.psd',               (100, 200)),
+    ('hidden-groups.psd',       (100, 200)),
+    ('hidden-layer.psd',        (100, 150)),
+    ('history.psd',             (100, 150)),
+    ('mask.psd',                (100, 150)),
+    ('note.psd',                (300, 300)),
+    ('pen-text.psd',            (300, 300)),
+    ('smart-object-slice.psd',  (100, 100)),
+    ('transparentbg.psd',       (100, 150)),
+    ('vector mask.psd',         (100, 150)),
+)
+
+@pytest.mark.parametrize(("filename", "size"), DIMENSIONS)
+def test_dimensions(filename, size):
+    w, h = size
+    psd = load_psd(filename)
+    assert psd.header.width == w
+    assert psd.header.height == h

File tests/utils.py

+# -*- coding: utf-8 -*-
+from __future__ import absolute_import, unicode_literals
+import os
+import psd_tools.reader
+
+DATA_PATH = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'psd_files')
+
+def load_psd(filename):
+    full_filename = os.path.join(DATA_PATH, filename)
+    with open(full_filename, 'rb') as f:
+        return psd_tools.reader.parse(f)
-; this is a tox config for running "psd-reader.py" script
+; this is a tox config for running psd-tools tests
 ; under different Python interpreters
 
 [tox]
 [testenv]
 deps=
     docopt >= 0.5
+    pytest
+    pytest-cov
+    coverage
 
 commands=
-    psd-tools.py []
+    py.test []