diff --git a/test/test_wordcloud.py b/test/test_wordcloud.py index f4378039..f667e9fc 100644 --- a/test/test_wordcloud.py +++ b/test/test_wordcloud.py @@ -1,4 +1,5 @@ from wordcloud import WordCloud, get_single_color_func, ImageColorGenerator +import os import numpy as np from random import Random from nose.tools import (assert_equal, assert_greater, assert_true, assert_false, @@ -229,6 +230,18 @@ def test_mask_contour(): assert_true(all(sm_array[100, 300] == [0, 0, 255])) +def test_test_mask_contour_transparent(): + # test if mask contour can be drawn on a transparent background + # https://github.com/amueller/word_cloud/pull/389 + examples_dir = os.path.realpath(os.path.join(os.path.dirname(__file__), '..', 'examples')) + mask_file = os.path.join(examples_dir, 'alice_mask.png') + mask = np.array(Image.open(mask_file)) + w = WordCloud(mode='RGBA', background_color=None, contour_color='blue', contour_width=2, mask=mask, + max_words=50, width=800, height=800) + w.generate(THIS) + w.to_file(NamedTemporaryFile(suffix=".png").name) + + def test_single_color_func(): # test single color function for different color formats random = Random(42)