Mercurial > hg > FileServer
changeset 7:4d1852cfc077
rudimentary test for directory server
author | Jeff Hammel <jhammel@mozilla.com> |
---|---|
date | Wed, 29 Feb 2012 14:48:53 -0800 |
parents | 623358c3ebde |
children | 782e15b86b86 |
files | tests/doctest.txt tests/test.py |
diffstat | 2 files changed, 16 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/tests/doctest.txt Wed Feb 29 14:44:04 2012 -0800 +++ b/tests/doctest.txt Wed Feb 29 14:48:53 2012 -0800 @@ -19,3 +19,17 @@ 200 >>> response.body == file(filename).read() True + +Make a directory server:: + + >>> directory = os.path.join(here, 'example') + >>> os.path.exists(directory) and os.path.isdir(directory) + True + >>> app = fileserver.DirectoryServer(directory) + >>> testapp = TestApp(app) + >>> response = testapp.get('/') + >>> response.status + 200 + >>> 'helloworld.txt' in response.body + True +
--- a/tests/test.py Wed Feb 29 14:44:04 2012 -0800 +++ b/tests/test.py Wed Feb 29 14:48:53 2012 -0800 @@ -22,8 +22,8 @@ doctest_args['optionflags'] = doctest.REPORT_ONLY_FIRST_FAILURE # gather tests - tests = [ test for test in os.listdir(directory) - if test.endswith('.txt') ] + tests = [test for test in os.listdir(directory) + if test.endswith('.txt')] # run the tests for test in tests: