Skip to content

Commit

Permalink
Fix selftest so it returns a useful return code
Browse files Browse the repository at this point in the history
  • Loading branch information
djhoese committed Apr 21, 2018
1 parent 3a75937 commit 1c99dbd
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 14 deletions.
File renamed without changes.
2 changes: 1 addition & 1 deletion LICENSE.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The aggdraw interface, and associated modules and documentation are:

Copyright (c) 2011-2017 by AggDraw Developers
Copyright (c) 2011-2018 by AggDraw Developers
Copyright (c) 2003-2006 by Secret Labs AB
Copyright (c) 2003-2006 by Fredrik Lundh

Expand Down
35 changes: 22 additions & 13 deletions selftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
# -*- coding: iso-8859-1 -*-
# sanity check

import numpy as np
from PIL import Image
from aggdraw import Draw, Symbol, Brush, Pen, Path

import numpy as np
from aggdraw import *

def testdraw():
def test_draw():
"""
>>> draw = Draw("RGB")
Expand All @@ -27,9 +27,10 @@ def testdraw():
>>> draw.mode, draw.size
('RGB', (600, 800))
"""

def testflush():
def test_flush():
"""
>>> im = Image.new("RGB", (600, 800))
Expand All @@ -38,7 +39,8 @@ def testflush():
'RGB'
"""

def testpen():

def test_pen():
"""
>>> pen = Pen("black")
Expand All @@ -53,7 +55,8 @@ def testpen():
"""

def testbrush():

def test_brush():
"""
>>> brush = Brush("black")
Expand All @@ -66,7 +69,8 @@ def testbrush():
"""

def testgraphics():

def test_graphics():
"""
>>> draw = Draw("RGB", (500, 500))
Expand All @@ -93,7 +97,8 @@ def testgraphics():
"""

def testgraphics2():

def test_graphics2():
"""See issue #14
>>> symbol = Symbol("M400 200 L400 400")
Expand All @@ -102,11 +107,13 @@ def testgraphics2():
>>> canvas = Draw(image)
>>> canvas.symbol((0, 0), symbol, pen)
>>> image_pointer = canvas.flush()
>>> print(np.asarray(image).sum())
>>> assert np.asarray(image).sum() == 50800
"""

def testpath():

def test_path():
"""
>>> p = Path()
Expand All @@ -131,7 +138,8 @@ def testpath():
"""

def testsymbol():

def test_symbol():
"""
>>> s = Symbol("M0,0L0,0L0,0L0,0Z")
Expand All @@ -146,7 +154,8 @@ def testsymbol():
"""

def testtransform():

def test_transform():
"""
>>> draw = Draw("RGB", (500, 500))
Expand All @@ -160,12 +169,12 @@ def testtransform():
"""



if __name__ == "__main__":
# use doctest to make sure the test program behaves as documented!
import doctest, selftest
import sys, doctest, selftest
status = doctest.testmod(selftest)
if status[0]:
print("*** %s tests of %d failed." % status)
else:
print("%s tests passed." % status[1])
sys.exit(status[0])

0 comments on commit 1c99dbd

Please sign in to comment.