Changeset 2436
- Timestamp:
- 06/14/09 16:40:41
- Files:
-
- branches/python3/cherrypy/test/test_session.py (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/python3/cherrypy/test/test_session.py
r2403 r2436 57 57 if hasattr(cherrypy, "session"): 58 58 del cherrypy.session 59 cls = getattr(sessions, newtype.title() + 'Session') 60 if cls.clean_thread: 61 cls.clean_thread.stop() 62 cls.clean_thread.unsubscribe() 63 del cls.clean_thread 59 64 setsessiontype.exposed = True 60 65 setsessiontype._cp_config = {'tools.sessions.on': False} … … 107 112 108 113 def session_cookie(self): 114 # Must load() to start the clean thread. 109 115 cherrypy.session.load() 110 116 return cherrypy.session.id … … 307 313 def test_7_session_cookies(self): 308 314 self.getPage('/setsessiontype/ram') 315 self.getPage('/clear') 309 316 self.getPage('/session_cookie') 310 317 # grab the cookie ID … … 322 329 self.assertBody(id1) 323 330 self.assertEqual(list(sessions.RamSession.cache.keys()), [id1]) 324 325 # Wait 0.5 seconds to separate the two sessions326 time.sleep(0.5)327 331 328 332 # Simulate a browser close by just not sending the cookies … … 336 340 self.assertNotEqual(id1, id2) 337 341 self.assertEqual(set(sessions.RamSession.cache.keys()), set([id1, id2])) 338 # Wait for the session.timeout on the first session (1 second) 339 time.sleep(1) 340 cache = list(sessions.RamSession.cache.keys()) 341 if cache != [id2]: 342 if set(cache) == set([id1, id2]): 343 self.fail("The first session did not time out.") 344 elif not cache: 345 self.fail("The second session may have been cleaned up " 346 "prematurely, but it may just be thread timing.") 347 else: 348 self.fail("Unknown session id in cache: %r", cache) 349 # Wait for the session.timeout on the second session (1 second) 350 time.sleep(1) 342 343 # Wait for the session.timeout on both sessions 344 time.sleep(2.5) 351 345 cache = list(sessions.RamSession.cache.keys()) 352 346 if cache:

