Skip to content

Commit

Permalink
Fixed PNG test (passes both locally and on travis)
Browse files Browse the repository at this point in the history
  • Loading branch information
arekbulski committed Aug 22, 2016
1 parent 5828a9e commit 7032548
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions tests/formats/graphics/test_png.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import unittest
import unittest, os
ontravis = 'TRAVIS' in os.environ

from construct.lib.container import Container
from construct.formats.graphics.png import png_file

class TestPngFormat(unittest.TestCase):

def test_parse(self):
with open('sample.png','rb') as f:
filename = 'sample.png' if ontravis else 'tests/sample.png'
with open(filename,'rb') as f:
data = f.read()
sample = png_file.parse(data)
# this raises syntax error, why?
#self.assertEqual(sample, Container({'chunks': [Container({'data': Container({'significant_alpha_bits': 8, 'significant_green_bits': 8, 'significant_red_bits': 8, 'significant_blue_bits': 8}), 'length': 4, 'type': 'sBIT', 'crc': 2080924808}), Container({'data': Container({'text': 'gnome-screenshot', 'keyword': 'Software'}), 'length': 25, 'type': 'tEXt', 'crc': 4010000190}), Container({'data': <construct.lib.container.LazyContainer object at 0x7ffb2034c418>, 'length': 8192, 'type': 'IDAT', 'crc': 1554473045}), Container({'data': <construct.lib.container.LazyContainer object at 0x7ffb2034c470>, 'length': 8192, 'type': 'IDAT', 'crc': 1490082961}), Container({'data': <construct.lib.container.LazyContainer object at 0x7ffb2034c4c8>, 'length': 8192, 'type': 'IDAT', 'crc': 4247891774}), Container({'data': <construct.lib.container.LazyContainer object at 0x7ffb2034c520>, 'length': 8192, 'type': 'IDAT', 'crc': 3667621403}), Container({'data': <construct.lib.container.LazyContainer object at 0x7ffb2034c578>, 'length': 7390, 'type': 'IDAT', 'crc': 1033426802}), Container({'data': None, 'length': 0, 'type': 'IEND', 'crc': 2923585666})], 'image_header': Container({'crc': 1278104008, 'color_type': 'truewithalpha', 'bit_depth': 8, 'height': 438, 'compression_method': 'deflate', 'width': 732, 'length': 13, 'filter_method': 'adaptive5', 'interlace_method': 'none'})}))

0 comments on commit 7032548

Please sign in to comment.