# HG changeset patch # User Jeff Hammel # Date 1330647644 28800 # Node ID 7c154953acc4604b5ee593c6cc14cb99279b4718 # Parent 53ec5144f84f0edcc0a080249d84e45b9f75a0b2 test reading the pages diff -r 53ec5144f84f -r 7c154953acc4 tests/test_ttw.txt --- a/tests/test_ttw.txt Thu Mar 01 15:59:18 2012 -0800 +++ b/tests/test_ttw.txt Thu Mar 01 16:20:44 2012 -0800 @@ -5,6 +5,7 @@ The obligatory imports:: + >>> import urllib2 >>> from simpypi.factory import factory Create a WSGI app:: @@ -13,8 +14,24 @@ Now wrap it in a server:: - >>> server = testserver(app, 'localhost', 64321) + >>> port = 64321 + >>> server = testserver(app, 'localhost', port) >>> server.start() + >>> url = 'http://localhost:%d/' % port + +Get the home page:: + + >>> resource = urllib2.urlopen(url) + >>> contents = resource.read() + >>> 'Python Package Index' in contents + True + +Get the index page:: + + >>> resource = urllib2.urlopen(url + 'index') + >>> contents = resource.read() + >>> 'Simple Index' in contents + True Shut down the server::