Skip to content

Commit

Permalink
fix __repr__ of fake _RootGroup
Browse files Browse the repository at this point in the history
  • Loading branch information
kmike committed Nov 15, 2014
1 parent ae066ea commit 02ddb17
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
2 changes: 0 additions & 2 deletions src/psd_tools/debug.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,3 @@ def _repr_pretty_(self, p, cycle):
p.pretty(getattr(self, field))

return _PrettyNamedtupleMixin


4 changes: 4 additions & 0 deletions src/psd_tools/user_api/psd_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,10 @@ def visible(self):
def visible_global(self):
return True

@property
def name(self):
return "_RootGroup"


def combined_bbox(layers):
"""
Expand Down
9 changes: 9 additions & 0 deletions tests/test_info.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import, unicode_literals

import re
from psd_tools import PSDImage
from psd_tools.constants import TaggedBlock, SectionDivider, BlendMode
from .utils import decode_psd


def test_1layer_name():
psd = decode_psd('1layer.psd')
layers = psd.layer_and_mask_data.layers.layer_records
Expand All @@ -17,6 +19,7 @@ def test_1layer_name():
assert block.key == TaggedBlock.UNICODE_LAYER_NAME
assert block.data == 'Фон'


def test_groups():
psd = decode_psd('group.psd')
layers = psd.layer_and_mask_data.layers.layer_records
Expand All @@ -25,6 +28,7 @@ def test_groups():
assert layers[1].tagged_blocks[3].key == TaggedBlock.SECTION_DIVIDER_SETTING
assert layers[1].tagged_blocks[3].data.type == SectionDivider.BOUNDING_SECTION_DIVIDER


def test_api():
image = PSDImage(decode_psd('1layer.psd'))
assert len(image.layers) == 1
Expand All @@ -36,3 +40,8 @@ def test_api():
assert layer.opacity == 255
assert layer.blend_mode == BlendMode.NORMAL


def test_fakeroot_layer_repr():
img = PSDImage(decode_psd('1layer.psd'))
fakeroot = img.layers[0].parent
assert re.match(r"<psd_tools.Group: u?'_RootGroup', layer_count=1>", repr(fakeroot)), repr(fakeroot)

0 comments on commit 02ddb17

Please sign in to comment.