SessionBase.cycle_key() discards session data if _session_cache isn't populated
    
    
    
      
      
      
        
The cycle_key() method will use an empty dict for session data if it had not previously been loaded. The docstring says the function is there specifically to avoid losing sesison data, and the behavior feels inconsistent. This won't be noticed on most sites, as the AuthenticationMiddleware accesses the session on every request. However, it did cause problems for me in unittests for some views.
       
     
   
 
      
        
        
          Change History
          (9)
        
          
          
  
  
  
    
      | Owner: | 
      
        changed from nobody to InvalidInterrupt
       | 
    
    
      | Status: | 
      
        new → assigned
       | 
    
  
 
           
          
  
  
  
    
      | Summary: | 
      
        SessionBase.cycle_key may discard session data → SessionBase.cycle_key() discards session data if _session_cache isn't populated
       | 
    
    
      | Triage Stage: | 
      
        Unreviewed → Accepted
       | 
    
  
 
           
          
          
  
  
  
    
      | Resolution: | 
      
        → fixed
       | 
    
    
      | Status: | 
      
        assigned → closed
       | 
    
  
 
           
          
          
          
          
          
         
       
     
        
    
    
Could you please give an example test that demonstrates the issue?