2008-09-20 18 views

cevap

1

Aslında WebTest, sürece ben yazmak ve nasıl yapılacağını gösterir GAEUnit projesine sample application ekledik

+0

Yama' webtest/__ init __ py' artık gerekli değildir.

İşte örnek uygulaması 'test' dizini gelen 'web_tests.py' dosya. app: çağırdıysanız showbrowser' işlevi. Https://github.com/Pylons/webtest/commit/78076424c219935ee556aab84d943d5949530531 ve https://github.com/Pylons/webtest/commit/53889b57fe16c57fd7f532953d2e15bfaba7e5b3 –

11

init__.py webtest içinde

import webbrowser 

/__ kum havuzu içinde çalışmalarını açıklama yok gibi GAEUnit kullanarak bir web testi yapın. Örnek, 'webtest' modülünün biraz değiştirilmiş bir versiyonunu içerir ('David Gober tarafından tavsiye edildiği gibi' webbrowser 'içe aktarılır). webbrowser sadece `webtest tarafından ithal edildiği gibi,

import unittest 
from webtest import TestApp 
from google.appengine.ext import webapp 
import index 

class IndexTest(unittest.TestCase): 

    def setUp(self): 
    self.application = webapp.WSGIApplication([('/', index.IndexHandler)], debug=True) 

    def test_default_page(self): 
    app = TestApp(self.application) 
    response = app.get('/') 
    self.assertEqual('200 OK', response.status) 
    self.assertTrue('Hello, World!' in response) 

    def test_page_with_param(self): 
    app = TestApp(self.application) 
    response = app.get('/?name=Bob') 
    self.assertEqual('200 OK', response.status) 
    self.assertTrue('Hello, Bob!' in response) 
+0

Bkz. Webbrowser yalnızca webtest/__ init __. 'webtest.app: showbrowser' işleviyle çağrılırsa çağrılır. Https://github.com/Pylons/webtest/commit/78076424c219935ee556aab84d943d5949530531 ve https://github.com/Pylons/webtest/commit/53889b57fe16c57fd7f532953d2e15bfaba7e5b3 adresine bakın. –

İlgili konular