# -*- coding: utf-8 -*- import itertools import os.path from system_tests import CaseMeta, path def read_file(filename): with open(filename, 'r') as f: return f.read() class AddMinusPSOption(metaclass=CaseMeta): cls_location = os.path.dirname(__file__) url = "http://dev.exiv2.org/issues/922" bug_jpg_file = path("$data_path/exiv2-bug922.jpg") IPTC_file = path("$data_path/iptc-psAPP13-wIPTCempty-psAPP13-wIPTC.jpg") files = [ path("$data_path/{!s}".format(img)) for img in "exiv2-bug922.png exiv2-bug922.tif exiv2-bug922a.jpg".split() ] png_bug_file = files[0] tif_bug_file = files[1] jpg_bug_file = files[2] commands = [ "$exiv2 -pX $bug_jpg_file", "$exiv2 -pX $IPTC_file", ] + list( itertools.chain.from_iterable([ "$exiv2 -pX " + fname, "$exiv2 -pS " + fname ] for fname in files) ) stdout = [ read_file( os.path.join(cls_location, "issue_922_exiv2_pX_bug922_jpg_output") ), """ """, """ this is the title """, """STRUCTURE OF PNG FILE: $png_bug_file address | chunk | length | data | checksum 8 | IHDR | 13 | ...@........ | 0x7f775da4 33 | zTXt | 8769 | Raw profile type exif..x...[r. | 0x4a89d860 8814 | zTXt | 270 | Raw profile type iptc..x.=QKn. | 0x29f9e2d3 9096 | iTXt | 2524 | XML:com.adobe.xmp.......]....UKqD2s.(.q....=x.l.\ | 0xc177fe83 54182 | IDAT | 8192 | .i.{!!B0...C!4.p..`D g`....... | 0x0e276268 62386 | IDAT | 8192 | .*.].4..Q..}(9...S0&.......T.9 | 0x297bb2db 70590 | IDAT | 8192 | ..k...6....g.1..}.].&.H....... | 0x05f6f4ef 78794 | IDAT | 8192 | .j..S.........z..!U.G0*.m%..09 | 0xe0946eb5 86998 | IDAT | 8192 | .....t.>!.....6^.<..;..?.$I..M | 0x843ecce0 95202 | IDAT | 8192 | W.&5.5J........FW`....3.N.9Pk; | 0x3a3dfeee 103406 | IDAT | 8192 | .....d.z".`...v=g-..-.c8...Z.5 | 0x65d6df49 111610 | IDAT | 8192 | .."...o<&."....1M....1&. ..5.. | 0x700b8cde 119814 | IDAT | 8192 | k........!..B*.....\*.(!..0.s. | 0x9b33b5b7 128018 | IDAT | 3346 | .Y.L@I$M.Z[.0A ...K#.t.0+.G(.j | 0x18044b20 131376 | IEND | 0 | | 0xae426082 """, """ this is a title """, """STRUCTURE OF TIFF FILE (MM): $tif_bug_file address | tag | type | count | offset | value 10 | 0x0100 ImageWidth | SHORT | 1 | | 40 22 | 0x0101 ImageLength | SHORT | 1 | | 470 34 | 0x0102 BitsPerSample | SHORT | 3 | 182 | 8 8 8 46 | 0x0103 Compression | SHORT | 1 | | 5 58 | 0x0106 PhotometricInterpretation | SHORT | 1 | | 2 70 | 0x0111 StripOffsets | LONG | 1 | | 2694 82 | 0x0112 Orientation | SHORT | 1 | | 6 94 | 0x0115 SamplesPerPixel | SHORT | 1 | | 3 106 | 0x0116 RowsPerStrip | SHORT | 1 | | 1092 118 | 0x0117 StripByteCounts | LONG | 1 | | 5086 130 | 0x011c PlanarConfiguration | SHORT | 1 | | 1 142 | 0x013d Predictor | SHORT | 1 | | 2 154 | 0x0153 SampleFormat | SHORT | 3 | 188 | 1 1 1 166 | 0x02bc XMLPacket | BYTE | 2500 | 194 | the rest drink soda the Brits are in the bar the Germans like beer """, """STRUCTURE OF JPEG FILE: $jpg_bug_file address | marker | length | data 0 | 0xffd8 SOI 2 | 0xffe1 APP1 | 14862 | Exif..II*...................... 14866 | 0xffe1 APP1 | 2720 | http://ns.adobe.com/xap/1.0/.