Ignore:
Timestamp:
Apr 18, 2011 11:16:39 AM (13 years ago)
Author:
vmaksymiv
Message:

pep8 fixes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • quintagroup.captcha.core/trunk/quintagroup/captcha/core/tests/testWidget.py

    r2542 r3128  
    1212testPatch() 
    1313 
     14 
    1415def addTestLayer(self): 
    1516    # Install test_captcha skin layer 
     
    1920    skinName = skins.getDefaultSkin() 
    2021    paths = map(string.strip, skins.getSkinPath(skinName).split(',')) 
    21     paths.insert(paths.index('custom')+1, 'test_captcha') 
     22    paths.insert(paths.index('custom') + 1, 'test_captcha') 
    2223    skins.addSkinSelection(skinName, ','.join(paths)) 
    2324    self._refreshSkinData() 
     
    3435        self.absolute_url = self.portal['index_html'].absolute_url_path() 
    3536 
    36         self.basic_auth = ':'.join((portal_owner,default_password)) 
     37        self.basic_auth = ':'.join((portal_owner, default_password)) 
    3738        self.captcha_key = self.portal.captcha_key 
    3839 
    3940    def testImage(self): 
    4041        path = '%s/test_form' % self.absolute_url 
    41         response = self.publish(path, self.basic_auth, request_method='GET').getBody() 
     42        response = self.publish(path, self.basic_auth, 
     43                                request_method='GET').getBody() 
    4244        patt = re.compile(IMAGE_PATT % self.portal.absolute_url()) 
    4345        match_obj = patt.search(response) 
    4446 
    4547        img_url = match_obj.group(1) 
    46         content_type = self.publish('/plone' + img_url, self.basic_auth).getHeader('content-type') 
     48        res = self.publish('/plone' + img_url, self.basic_auth) 
     49        content_type = res.getHeader('content-type') 
    4750        self.assert_(content_type.startswith('image')) 
    4851 
    4952    def testSubmitRightCaptcha(self): 
    5053        hashkey = self.portal.getCaptcha() 
    51         # index of word number starts from 1, but index of dictionary starts from 0 
    52         key = getWord(int(parseKey(decrypt(self.captcha_key, hashkey))['key'])-1 ) 
     54        # index of word number starts from 1, 
     55        # but index of dictionary starts from 0 
     56        decrypted_key = decrypt(self.captcha_key, hashkey) 
     57        key = getWord(int(parseKey(decrypted_key)['key']) - 1) 
    5358        parameters = 'form.submitted=1&key=%s' % key 
    5459        path = '%s/test_form?%s' % (self.absolute_url, parameters) 
    5560        extra = {'hashkey': hashkey, 
    5661                 'form.button.Save': 'Save'} 
    57         response = self.publish(path, self.basic_auth, extra=extra, request_method='GET').getBody() 
     62        response = self.publish(path, self.basic_auth, extra=extra, 
     63                                request_method='GET').getBody() 
    5864        self.assert_(not NOT_VALID.search(response)) 
    5965 
     
    6470        extra = {'hashkey': hashkey, 
    6571                 'form.button.Save': 'Save'} 
    66         response = self.publish(path, self.basic_auth, extra=extra, request_method='GET').getBody() 
     72        response = self.publish(path, self.basic_auth, extra=extra, 
     73                                request_method='GET').getBody() 
    6774        self.assert_(NOT_VALID.search(response)) 
    6875 
    6976    def testSubmitRightCaptchaTwice(self): 
    7077        hashkey = self.portal.getCaptcha() 
    71         key = getWord(int(parseKey(decrypt(self.captcha_key, hashkey))['key'])-1) 
    72         parameters = 'form.submitted=1&key=%s'%key 
    73         path = '%s/test_form?%s'%(self.absolute_url, parameters) 
     78        decrypted_key = decrypt(self.captcha_key, hashkey) 
     79        key = getWord(int(parseKey(decrypted_key)['key']) - 1) 
     80        parameters = 'form.submitted=1&key=%s' % key 
     81        path = '%s/test_form?%s' % (self.absolute_url, parameters) 
    7482        extra = {'hashkey': hashkey, 
    7583                 'form.button.Save': 'Save'} 
    7684        self.publish(path, self.basic_auth, extra=extra, request_method='GET') 
    77         response = self.publish(path, self.basic_auth, extra=extra, request_method='GET').getBody() 
     85        response = self.publish(path, self.basic_auth, extra=extra, 
     86                                request_method='GET').getBody() 
    7887 
    7988        self.assert_(NOT_VALID.search(response)) 
     
    8291        # captcha core related issue, described in 
    8392        # in http://plone.org/products/plone-comments/issues/5 
    84         resp = self.publish(self.portal.absolute_url(1)+"/captcha_widget") 
     93        resp = self.publish(self.portal.absolute_url(1) + "/captcha_widget") 
    8594        self.assertEqual(resp.status / 100, 2) 
     95 
    8696 
    8797def test_suite(): 
Note: See TracChangeset for help on using the changeset viewer.