diff options
| author | ianb <devnull@localhost> | 2007-12-13 22:23:12 +0000 |
|---|---|---|
| committer | ianb <devnull@localhost> | 2007-12-13 22:23:12 +0000 |
| commit | 47807b6f4cd6fca6f1231987f856c2e488770f33 (patch) | |
| tree | e5c0a08e022981564ea41877b106f278e7726294 /docs | |
| parent | 44f334967441aa246bbee05d1991253d41a6eca0 (diff) | |
| download | webtest-47807b6f4cd6fca6f1231987f856c2e488770f33.tar.gz | |
some examples and whatnot for a presentation
Diffstat (limited to 'docs')
| -rw-r--r-- | docs/chipy-presentation/about.txt | 7 | ||||
| -rw-r--r-- | docs/chipy-presentation/comparisons.txt | 66 | ||||
| -rw-r--r-- | docs/chipy-presentation/proxy_example.py | 5 | ||||
| -rw-r--r-- | docs/chipy-presentation/proxy_example.txt | 92 |
4 files changed, 170 insertions, 0 deletions
diff --git a/docs/chipy-presentation/about.txt b/docs/chipy-presentation/about.txt new file mode 100644 index 0000000..e453c1c --- /dev/null +++ b/docs/chipy-presentation/about.txt @@ -0,0 +1,7 @@ +WebTest +------- + +* Functional testing for applications +* Doesn't require an HTTP server +* Integrates well with any test runner (unittest, doctest, py.test, + nose) diff --git a/docs/chipy-presentation/comparisons.txt b/docs/chipy-presentation/comparisons.txt new file mode 100644 index 0000000..88daadd --- /dev/null +++ b/docs/chipy-presentation/comparisons.txt @@ -0,0 +1,66 @@ +Zope: + http://cheeseshop.python.org/pypi/zope.testbrowser/3.4.2 + + Browser-centric (vs. application-centric) + Slightly verbose + Works over HTTP (WSGI with wsgi_intercept) + Has forms, etc (Mechanize) + Next best (after WebTest) + +Django: + http://www.djangoproject.com/documentation/testing/ + + Reasonably system + Slightly verbose + Works over Django request system (not WSGI) + Slightly leaky + No forms + +CherryPy/TurboGears 1: + http://docs.turbogears.org/1.0/Testing#testing-your-view + + Very leaky! + Tests happen via side effects + Global objects everywhere + Can call directly into controllers + No forms + +Rails: + http://manuals.rubyonrails.com/read/chapter/28 + + Call directly into controller + Actually instantiate the controller in your tests + The main functionality is in a TestCase subclass + Has some XML/HTML inspection + Vigorous debate on best practice: + http://www.anarchogeek.com/articles/2007/9/16/rails-where-the-boundries-are-pushed + This is not a good thing + Mocks all over the place :( + +---- + +Twill: + http://twill.idyll.org/ + + Works over HTTP (WSGI with wsgi_intercept) + Lots of form support (Mechanize) + Simple-looking tests + Not a complete language + +Selenium: + http://www.openqa.org/selenium/ + + Works in a browser + Awkward language + Recorders exist + Satisfying to watch run + +Windmill: + http://windmill.osafoundation.org/ + + Like a mix of Twill and Selenium? + Uses a browser IDE like Selenium + Fancy Javascript recorder? + Experimental command-line + Browser can report back to code, like the (confusing) "drive" mode + in Selenium diff --git a/docs/chipy-presentation/proxy_example.py b/docs/chipy-presentation/proxy_example.py new file mode 100644 index 0000000..bb86ad4 --- /dev/null +++ b/docs/chipy-presentation/proxy_example.py @@ -0,0 +1,5 @@ +import doctest + +if __name__ == '__main__': + doctest.testfile('proxy_example.txt', optionflags=doctest.ELLIPSIS) + diff --git a/docs/chipy-presentation/proxy_example.txt b/docs/chipy-presentation/proxy_example.txt new file mode 100644 index 0000000..26efbcd --- /dev/null +++ b/docs/chipy-presentation/proxy_example.txt @@ -0,0 +1,92 @@ + >>> from wsgiproxy.exactproxy import proxy_exact_request + >>> from webtest import TestApp + >>> app = TestApp(proxy_exact_request) + >>> res = app.get('http://python.org') + >>> res + <200 OK text/html body='<!DOCTYPE...\n\n'/15978> + >>> print res + Response: 200 OK + Date: ... + Server: Apache/2.2.3 (Debian) DAV/2 SVN/1.4.2 mod_ssl/2.2.3 OpenSSL/0.9.8c + Last-Modified: ... + ETag: ... + Accept-Ranges: bytes + Content-Type: text/html + Content-Length: ... + ... + >>> from wsgifilter.proxyapp import DebugHeaders + >>> app = TestApp(DebugHeaders(proxy_exact_request)) + >>> app.get('http://python.org/') + Incoming headers: (GET http://python.org/ SCRIPT_NAME='') + Host: python.org:80 + Outgoing headers: (200 OK) + Date: ... + Server: Apache/2.2.3 (Debian) DAV/2 SVN/1.4.2 mod_ssl/2.2.3 OpenSSL/0.9.8c + Last-Modified: ... + Etag: ... + Accept-Ranges: bytes + Content-Length: ... + Content-Type: text/html + <200 OK text/html body='<!DOCTYPE...\n\n'/15978> + >>> app = TestApp(proxy_exact_request) + >>> res = app.get('http://python.org') + >>> res.lxml + <Element html at ...> + >>> for a in res.lxml.xpath('//a'): + ... if a.get('href').startswith('http:'): + ... continue + ... print a.get('href'), a.text_content() + / + #left-hand-navigation + #content-body + /search Advanced Search + /about/ About + /news/ News + /doc/ Documentation + /download/ Download + /community/ Community + /psf/ Foundation + /dev/ Core Development + /links/ Links + /download/releases/2.5.1 Quick Links (2.5.1) + /ftp/python/2.5.1/python-2.5.1.msi Windows Installer + /ftp/python/2.5.1/Python-2.5.1.tar.bz2 Source Distribution + /community/jobs Python Jobs + /psf/donations/ Donate to the PSF + /about/success/usa + <BLANKLINE> + about/success/rackspace Rackspace + about/success/ilm Industrial Light and Magic + about/success/astra AstraZeneca + about/success/honeywell Honeywell + about/success and many others + /about/quotes more... + /doc/topics/database Databases + /doc/topics/database/modules Others + /community/sigs/current/edu-sig Education + /about/apps Networking + /about/apps Software Development + /about/apps Game Development + /about/apps more... + /psf/license open source license + /psf Python Software Foundation (PSF) + /about Read more + /download try Python now + /download/releases/3.0 second alpha release + /download/releases/3.0 first alpha release + /channews.rdf RSS + /about/website Website maintained by the Python community + /psf Python Software Foundation + /about/legal Legal Statements + >>> res = res.click('Legal Statements') + >>> res.request.url + 'http://python.org/about/legal' + >>> res.status + '301 Moved Permanently' + >>> res = res.follow() + >>> #res.showbrowser() + >>> res.html.html.head.title + <title>Legal Statements</title> + >>> import re + >>> re.search(r'<title>(.*?)</title>', res.body).group(1) + 'Legal Statements' |
