def _test_tags_read(filename=None):
    import sys
    if filename is None:
        if len(sys.argv) != 2:
            filename = '/tmp/libtiff_tags_write.tiff'
            if not os.path.isfile (filename):
                print 'Run `%s <filename>` for testing.' % (__file__)
                return
        else:
            filename = sys.argv[1]
    tiff = TIFF.open(filename)
    tmp = tiff.GetField("Artist")
    assert tmp=="A Name","Tag 'Artist' did not read the correct value (Got '%s'; Expected 'A Name')" % (tmp,)
    tmp = tiff.GetField("DocumentName")
    assert tmp=="","Tag 'DocumentName' did not read the correct value (Got '%s'; Expected empty string)" % (tmp,)
    tmp = tiff.GetField("PrimaryChromaticities")
    assert tmp==[1,2,3,4,5,6],"Tag 'PrimaryChromaticities' did not read the correct value (Got '%r'; Expected '[1,2,3,4,5,6]'" % (tmp,)
    tmp = tiff.GetField("BitsPerSample")
    assert tmp==8,"Tag 'BitsPerSample' did not read the correct value (Got %s; Expected 8)" % (str(tmp),)
    tmp = tiff.GetField("ColorMap")
    try:
        assert len(tmp) == 3,"Tag 'ColorMap' should be three arrays, found %d" % len(tmp)
        assert len(tmp[0])==256,"Tag 'ColorMap' should be three arrays of 256 elements, found %d elements" % len(tmp[0])
        assert len(tmp[1])==256,"Tag 'ColorMap' should be three arrays of 256 elements, found %d elements" % len(tmp[1])
        assert len(tmp[2])==256,"Tag 'ColorMap' should be three arrays of 256 elements, found %d elements" % len(tmp[2])
    except __HOLE__:
        print "Tag 'ColorMap' has the wrong shape of 3 arrays of 256 elements each"
        return

    print "Tag Read: SUCCESS"
dataset/ETHPy150Open pearu/pylibtiff/libtiff/libtiff_ctypes.py/_test_tags_read