Changeset 2451 in products


Ignore:
Timestamp:
Jun 2, 2010 12:47:03 PM (9 years ago)
Author:
mylan
Message:

Added test is dynamic captha workable with current PIL in plone4 version (merged from /trunk@3489)

Location:
quintagroup.captcha.core/branches/plone4
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • quintagroup.captcha.core/branches/plone4

    • Property svn:mergeinfo set to /quintagroup.captcha.core/trunk:2450
  • quintagroup.captcha.core/branches/plone4/quintagroup/captcha/core/tests/testDynamic.py

    r1992 r2451  
    11import string 
     2from os.path import abspath, dirname 
    23from base import * 
    34 
     
    67 
    78from testStatic import TestStaticValidator 
     9 
     10# Check PIL 
     11try: 
     12    from PIL import ImageFont 
     13    fontspath = abspath(dirname(dirname(__file__))) + '/data/fonts/vera/' 
     14    font = ImageFont.truetype(fontspath+'VeraBd.ttf', 27) 
     15except ImportError: 
     16    DYNAMIC_WORKABLE = False 
     17else: 
     18    DYNAMIC_WORKABLE = True 
     19 
    820 
    921class DynamicMixin: 
     
    2234            skins.addSkinSelection( skin, path ) 
    2335            self._refreshSkinData() 
     36 
     37 
     38class TestPIL(unittest.TestCase): 
     39     
     40    def testPILImageFont(self): 
     41        if not DYNAMIC_WORKABLE: 
     42            self.fail("You can not use Dynamic Captchas, only Static one " \ 
     43                "unless install PIL with _imagingft C module into python, " \ 
     44                "that is used for the current Zope instance.") 
     45 
    2446 
    2547class TestDynamic(DynamicMixin, ptc.FunctionalTestCase): 
     
    6688        self.assertTrue(img_html.status == 200, "Wrong response status: " \ 
    6789            "'%s', must be '200'" % img_html.status) 
    68          
     90 
    6991 
    7092class TestDynamicValidator(DynamicMixin, TestStaticValidator): 
     
    7799def test_suite(): 
    78100    suite = unittest.TestSuite() 
    79     suite.addTest(unittest.makeSuite(TestDynamic)) 
    80     suite.addTest(unittest.makeSuite(TestDynamicValidator)) 
     101    suite.addTest(unittest.makeSuite(TestPIL)) 
     102    if DYNAMIC_WORKABLE: 
     103        suite.addTest(unittest.makeSuite(TestDynamic)) 
     104        suite.addTest(unittest.makeSuite(TestDynamicValidator)) 
    81105    return suite 
Note: See TracChangeset for help on using the changeset viewer.