mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-27 02:16:19 +03:00
4de5477b61
With the introduction and use of pytest, it is simple and easy to execute specific tests in isolation through documented command line arguments. Either by specifying the module path or through the `-k EXPRESSION` argument. There is no longer any need to provide the boilerplate: if __name__ == '__main__': unittest.main() To every test file. It is simply noise. The pattern remains in test files that aren't named with `test_*` as those files are not discovered and executed by pytest by default.
34 lines
1.1 KiB
Python
34 lines
1.1 KiB
Python
from __future__ import division
|
|
from .helper import unittest, PillowLeakTestCase
|
|
import sys
|
|
from PIL import Image, features, ImageDraw, ImageFont
|
|
|
|
|
|
@unittest.skipIf(sys.platform.startswith('win32'), "requires Unix or macOS")
|
|
class TestTTypeFontLeak(PillowLeakTestCase):
|
|
# fails at iteration 3 in master
|
|
iterations = 10
|
|
mem_limit = 4096 # k
|
|
|
|
def _test_font(self, font):
|
|
im = Image.new('RGB', (255, 255), 'white')
|
|
draw = ImageDraw.ImageDraw(im)
|
|
self._test_leak(lambda: draw.text((0, 0), "some text "*1024, # ~10k
|
|
font=font, fill="black"))
|
|
|
|
@unittest.skipIf(not features.check('freetype2'),
|
|
"Test requires freetype2")
|
|
def test_leak(self):
|
|
ttype = ImageFont.truetype('Tests/fonts/FreeMono.ttf', 20)
|
|
self._test_font(ttype)
|
|
|
|
|
|
class TestDefaultFontLeak(TestTTypeFontLeak):
|
|
# fails at iteration 37 in master
|
|
iterations = 100
|
|
mem_limit = 1024 # k
|
|
|
|
def test_leak(self):
|
|
default_font = ImageFont.load_default()
|
|
self._test_font(default_font)
|