def _test_main_thread(): cherrypy.server.wait() cherrypy._cputil._cpInitDefaultFilters() try: webtest.main() finally: thread.interrupt_main()
self.assertTrue('Thanks for your signing' in b.data) b.open('/c/%s/signatories' % (test_pid_to_cong if to_congress else test_pid)) self.assertTrue(comment in b.data) def test_sign_NL_NTC(self): self.make_sign_NL(to_congress=False) def test_sign_NL_TC(self): before = len(messages.query().list()) self.make_sign_NL(to_congress=True) after = len(messages.query().list()) self.assertEquals(before+3, after) # one msg gets added for each rep/sen def test_edit_sign(self): b = self.browser() self.login() b.open('/c/%s' % test_pid) self.assertTrue('Change your signature' in b.data) f = b.select_form(name="sign") comment = "I'm the creator of it" f['fname'], f['lname'] = 'fname', 'lname' f['comment'] = comment b.submit() self.assertTrue(b.path.startswith('/share')) self.assertTrue('Your signature has been changed' in b.data) b.open('/c/%s/signatories' % test_pid) self.assertTrue(comment in b.data) if __name__ == '__main__': webtest.main()
"""Tests for the template security feature.""" def testPrint(self): if PY2: tpl = "$code:\n print 'blah'" #print_function has been imported from __future__ so the print statement doesn't exist anymore self.assertRaises(SyntaxError, t, tpl) else: tpl = "$code:\n print('blah')" self.assertRaises(NameError, t(tpl)) def testRepr(self): if PY2: #this feature doesn't exist in Py3 anymore tpl = "$code:\n `1`" self.assertRaises(SecurityError, t, tpl) def testAttr(self): tpl = '$code:\n (lambda x: x+1).func_code' self.assertRaises(SecurityError, t, tpl) tpl = '$def with (a)\n$code:\n a.b = 3' self.assertRaises(SecurityError, t, tpl) #these two should execute themselves flawlessly t("$code:\n foo = {'a': 1}.items()")() if not PY2: t("$code:\n bar = {k:0 for k in [1,2,3]}")() if __name__ == "__main__": webtest.main()
def _test_main_thread(): try: webtest.WebCase.PORT = cherrypy.config.get('server.socket_port') webtest.main() finally: thread.interrupt_main()