forked from MostAwesomeDude/construct
-
Notifications
You must be signed in to change notification settings - Fork 153
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed PNG test (passes both locally and on travis)
- Loading branch information
1 parent
5828a9e
commit 7032548
Showing
1 changed file
with
5 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'})})) |