Хабр Курсы для всех
РЕКЛАМА
Практикум, Хекслет, SkyPro, авторские курсы — собрали всех и попросили скидки. Осталось выбрать!
>> [meako@meako_inspiron meako]$ twill-sh -= Welcome to twill! =- current page: *empty page* >> go "http://habr.ru" ==> at http://habrahabr.ru/ current page: http://habrahabr.ru/ >> follow "Люди" ==> at http://habrahabr.ru/people/ current page: http://habrahabr.ru/people/ >>
>>> twill.commands.go("http://habr.ru")
==> at http://habrahabr.ru/
'http://habrahabr.ru/'
>>> twill.commands.follow("Люди")
==> at http://habrahabr.ru/people/
'http://habrahabr.ru/people/'
>>> twill.commands.follow(u"Люди")
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "/usr/lib/python2.6/site-packages/twill-0.9-py2.6.egg/twill/commands.py", line 202, in follow
raise TwillAssertionError("no links match to '%s'" % (what,))
TwillAssertionError: <unprintable TwillAssertionError object>
#coding: utf-8
from django_webtest import WebTest
from test_utils.utils import twill_runner as twill
class TestTest(WebTest):
fixtures = ['cities.city.json', 'users.json']
def testTwill(self):
twill.setup()
try:
twill.go('/login/')
twill.code(200) # все ок
twill.showlinks() # печатает какую-то перекодированную несколько раз белиберду
twill.follow('Регистрация') # валится с no links match to Регистрация
finally:
twill.teardown()
def testWeb(self):
page = self.app.get('/login/')
page.click(u'Регистрация') # работает
from twill import add_wsgi_intercept, commands
def setup(self):
super(BaseHttpTestCase, self).setup()
app = AdminMediaHandler(WSGIHandler())
add_wsgi_intercept(self.IP, self.PORT, lambda: app)
Пишем функциональные/интеграционные тесты для проекта на django