Re-arrange tests, no functional change.

This commit is contained in:
Emil Mikulic 2011-04-17 19:00:04 +10:00
parent b6df049c49
commit 0b5d1d881c

View File

@ -51,7 +51,7 @@ def parse(resp):
hdrs[k] = v hdrs[k] = v
return (status, hdrs, body) return (status, hdrs, body)
class TestCases(unittest.TestCase): class TestHelper(unittest.TestCase):
def assertContains(self, body, *strings): def assertContains(self, body, *strings):
for s in strings: for s in strings:
self.assertTrue(s in body, self.assertTrue(s in body,
@ -71,6 +71,7 @@ class TestCases(unittest.TestCase):
"You requested an invalid URL: %s\n"%path, "You requested an invalid URL: %s\n"%path,
'Generated by darkhttpd') 'Generated by darkhttpd')
class TestDirList(TestHelper):
def test_dirlist_escape(self): def test_dirlist_escape(self):
fn = WWWROOT+"/escape#this" fn = WWWROOT+"/escape#this"
open(fn, "w").write("x"*12345) open(fn, "w").write("x"*12345)
@ -82,6 +83,9 @@ class TestCases(unittest.TestCase):
self.assertEquals(ord("#"), 0x23) self.assertEquals(ord("#"), 0x23)
self.assertContains(body, "escape%23this", "12345") self.assertContains(body, "escape%23this", "12345")
class TestCases(TestHelper):
pass # these get autogenerated in setUpModule()
def nerf(s): def nerf(s):
return re.sub("[^a-zA-Z0-9]", "_", s) return re.sub("[^a-zA-Z0-9]", "_", s)
@ -123,9 +127,7 @@ def makeCase(name, url, hdr_checker=None, body_checker=None,
def makeCases(name, url, hdr_checker=None, body_checker=None, def makeCases(name, url, hdr_checker=None, body_checker=None,
req_hdrs={"User-Agent": "test.py"}): req_hdrs={"User-Agent": "test.py"}):
# FIXME: 0.9 is broken
for http_ver in [None, "1.0", "1.1"]: for http_ver in [None, "1.0", "1.1"]:
#for http_ver in ["1.0", "1.1"]:
for endl in ["\n", "\r\n"]: for endl in ["\n", "\r\n"]:
makeCase(name, url, hdr_checker, body_checker, makeCase(name, url, hdr_checker, body_checker,
req_hdrs, http_ver, endl) req_hdrs, http_ver, endl)
@ -149,8 +151,5 @@ def setUpModule():
if __name__ == '__main__': if __name__ == '__main__':
setUpModule() setUpModule()
unittest.main() unittest.main()
#x = Conn().get("/xyz/../", "1.0")
#y = parse(x)
#print repr(y)
# vim:set ts=4 sw=4 et: # vim:set ts=4 sw=4 et: