azaghal / pydenticon

Pydenticon is a small utility library that can be used for deterministically generating identicons based on the hash of provided data.
BSD 3-Clause "New" or "Revised" License
66 stars 10 forks source link

Test failure concerning pillow #9

Closed nado closed 6 years ago

nado commented 6 years ago

Hi,

While running your tests with setup.py test I encountered an error

test_data_to_digest_byte_list_hex (tests.test_pydenticon.GeneratorTest) ... ok
test_data_to_digest_byte_list_hex_lookalike (tests.test_pydenticon.GeneratorTest) ... ok
test_data_to_digest_byte_list_raw (tests.test_pydenticon.GeneratorTest) ... ok
test_generate_ascii (tests.test_pydenticon.GeneratorTest) ... ok
test_generate_foreground (tests.test_pydenticon.GeneratorTest) ... ok
test_generate_format (tests.test_pydenticon.GeneratorTest) ... ERROR
test_generate_format_invalid (tests.test_pydenticon.GeneratorTest) ... ok
test_generate_image_basics (tests.test_pydenticon.GeneratorTest) ... ok
test_generate_image_compare (tests.test_pydenticon.GeneratorTest) ... ok
test_generate_inverted_ascii (tests.test_pydenticon.GeneratorTest) ... ok
test_generate_inverted_png (tests.test_pydenticon.GeneratorTest) ... ok
test_generate_matrix (tests.test_pydenticon.GeneratorTest) ... ok
test_get_bit (tests.test_pydenticon.GeneratorTest) ... ok
test_init_entropy (tests.test_pydenticon.GeneratorTest) ... ok
test_init_parameters (tests.test_pydenticon.GeneratorTest) ... ok

======================================================================
ERROR: test_generate_format (tests.test_pydenticon.GeneratorTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib64/python3.6/site-packages/PIL/JpegImagePlugin.py", line 620, in _save
    rawmode = RAWMODE[im.mode]
KeyError: 'RGBA'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/var/tmp/portage/dev-python/pydenticon-0.3/work/pydenticon-0.3/tests/test_pydenticon.py", line 242, in test_generate_format
    raw_image = generator.generate(data, 200, 200, output_format="jpeg")
  File "/var/tmp/portage/dev-python/pydenticon-0.3/work/pydenticon-0.3/pydenticon/__init__.py", line 338, in generate
    return self._generate_image(matrix, width, height, padding, foreground, background, output_format)
  File "/var/tmp/portage/dev-python/pydenticon-0.3/work/pydenticon-0.3/pydenticon/__init__.py", line 251, in _generate_image
    image.save(stream, format=image_format, optimize=True)
  File "/usr/lib64/python3.6/site-packages/PIL/Image.py", line 1969, in save
    save_handler(self, fp, filename)
  File "/usr/lib64/python3.6/site-packages/PIL/JpegImagePlugin.py", line 622, in _save
    raise IOError("cannot write mode %s as JPEG" % im.mode)
OSError: cannot write mode RGBA as JPEG

----------------------------------------------------------------------
Ran 15 tests in 0.218s

FAILED (errors=1)
Test failed: <unittest.runner.TextTestResult run=15 errors=1 failures=0>
error: Test failed: <unittest.runner.TextTestResult run=15 errors=1 failures=0>

This seems to be related to https://github.com/python-pillow/Pillow/issues/2609 My version of pillow is 5.3.0 and the failure is reproducible with py2.7 and 3.6.

azaghal commented 6 years ago

This issue has been fixed in Pydenticon 0.3.1. I'd suggest bumping the ebuild to use 0.3.1 (I didn't even know somebody was actually having an ebuild of Pydenticon, somewhat funny since just this early morning I actually switched over to Debian on my main machine after many years of using Gentoo :)

nado commented 6 years ago

Indeed, the tests succed in the ebuild now ;) I'm gathering ebuilds to push matrix synapse in gentoo tree, or at least in one overlay.