diff options
author | Elrond <elrond+mediagoblin.org@samba-tng.org> | 2012-02-04 20:54:14 +0100 |
---|---|---|
committer | Joar Wandborg <git@wandborg.com> | 2012-02-04 21:37:05 +0100 |
commit | ccca39f1d8a397f20d56406540785931ef7c419f (patch) | |
tree | b2413e5fbd192f6b767ad7c8d26ca20d8acf114b /mediagoblin/tests/test_exif.py | |
parent | 64da09e86a755e49832e3c324582c65d352632d4 (diff) | |
download | mediagoblin-ccca39f1d8a397f20d56406540785931ef7c419f.tar.lz mediagoblin-ccca39f1d8a397f20d56406540785931ef7c419f.tar.xz mediagoblin-ccca39f1d8a397f20d56406540785931ef7c419f.zip |
Fix EXIF based image rotation test
The test checks for a pixel value after rotation (good
idea!). But the value seems to be a bit different on some
platforms, so use a list of seen values.
Not the perfect solution, but it works.
Diffstat (limited to 'mediagoblin/tests/test_exif.py')
-rw-r--r-- | mediagoblin/tests/test_exif.py | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/mediagoblin/tests/test_exif.py b/mediagoblin/tests/test_exif.py index bfafe129..ed95045c 100644 --- a/mediagoblin/tests/test_exif.py +++ b/mediagoblin/tests/test_exif.py @@ -21,6 +21,11 @@ import Image from mediagoblin.tools.exif import exif_fix_image_orientation, \ extract_exif, clean_exif, get_gps_data, get_useful + +def assert_in(a, b): + assert a in b, "%r not in %r" % (a, b) + + GOOD_JPG = pkg_resources.resource_filename( 'mediagoblin.tests', os.path.join( @@ -42,6 +47,7 @@ GPS_JPG = pkg_resources.resource_filename( 'test_exif', 'has-gps.jpg')) + def test_exif_extraction(): ''' Test EXIF extraction from a good image @@ -130,6 +136,7 @@ def test_exif_extraction(): 32, 32, 32], 'field_length': 44}} + def test_exif_image_orientation(): ''' Test image reorientation based on EXIF data @@ -144,7 +151,10 @@ def test_exif_image_orientation(): assert image.size == (428, 640) # If this pixel looks right, the rest of the image probably will too. - assert image.getdata()[10000] == (41, 28, 11) + assert_in(image.getdata()[10000], + ((41, 28, 11), (43, 27, 11)) + ) + def test_exif_no_exif(): ''' @@ -160,6 +170,7 @@ def test_exif_no_exif(): assert gps == {} assert useful == {} + def test_exif_bad_image(): ''' Test EXIF extraction from a faithful, but bad image @@ -174,6 +185,7 @@ def test_exif_bad_image(): assert gps == {} assert useful == {} + def test_exif_gps_data(): ''' Test extractiion of GPS data @@ -186,4 +198,3 @@ def test_exif_gps_data(): 'direction': 25.674046740467404, 'altitude': 37.64365671641791, 'longitude': 18.016166666666667} - |