PDB用スニペット import pdb
import sys
for attr in ('stdin', 'stdout', 'stderr'):
setattr(sys, attr, getattr(sys, '__%s__' % attr))
pdb.set_trace()
helloworld_test.pyfrom webtest import TestApp
from helloworld import application
app = TestApp(application)
def test_index():
response = app.get('/')
assert 'Hello, webapp World!' in str(response)
認証のテストdef fake_login(email):
os.environ['USER_EMAIL'] = email
uid = email.split('@')[0]
os.environ['USER_ID'] = uid
os.environ["AUTH_DOMAIN"] = "gmail.com" return uid
def test_login():
fake_login('hoge@example.com')
response = app.get('/')
res = str(response)
logging.debug(res)
assert '200' in response.status[0:3]
assert 'Hello' in res
POSTのテストdef post_test():
response = app.get('/')
response = app.post('/sign', {"content": "hoge"})
res = str(response)
logging.debug(res)
assert '200' in response.status[0:3]
assert 'You wrote' in res
assert 'hoge' in res
|