Use setUp and tearDown to manage test file.

This commit is contained in:
Emil Mikulic 2011-04-17 19:01:52 +10:00
parent 0b5d1d881c
commit 449b78efaa

View File

@ -72,13 +72,15 @@ class TestHelper(unittest.TestCase):
'Generated by darkhttpd')
class TestDirList(TestHelper):
def setUp(self):
self.fn = WWWROOT+"/escape#this"
open(self.fn, "w").write("x"*12345)
def tearDown(self):
os.unlink(self.fn)
def test_dirlist_escape(self):
fn = WWWROOT+"/escape#this"
open(fn, "w").write("x"*12345)
try:
resp = Conn().get("/")
finally:
os.unlink(fn)
resp = Conn().get("/")
status, hdrs, body = parse(resp)
self.assertEquals(ord("#"), 0x23)
self.assertContains(body, "escape%23this", "12345")