File tree Expand file tree Collapse file tree 1 file changed +7
-12
lines changed Expand file tree Collapse file tree 1 file changed +7
-12
lines changed Original file line number Diff line number Diff line change 11import  os 
22import  pickle 
33import  re 
4- import  sys 
54import  tempfile 
65import  unittest 
76import  unittest .mock 
8- from  contextlib  import  contextmanager 
97from  test  import  support 
108from  test .support  import  import_helper 
119from  test .support  import  os_helper 
5654""" 
5755
5856
59- @contextmanager  
6057def  patch_screen ():
6158    """Patch turtle._Screen for testing without a display. 
6259
6360    We must patch the _Screen class itself instead of the _Screen 
6461    instance because instantiating it requires a display. 
6562    """ 
66-     m  =  unittest .mock .MagicMock ()
67-     m .__class__  =  turtle ._Screen 
68-     m .mode .return_value  =  "standard" 
69- 
70-     patch  =  unittest .mock .patch ('turtle._Screen.__new__' , return_value = m )
71-     try :
72-         yield  patch .__enter__ ()
73-     finally :
74-         patch .__exit__ (* sys .exc_info ())
63+     return  unittest .mock .patch (
64+         "turtle._Screen.__new__" ,
65+         ** {
66+             "return_value.__class__" : turtle ._Screen ,
67+             "return_value.mode.return_value" : "standard" ,
68+         },
69+     )
7570
7671
7772class  TurtleConfigTest (unittest .TestCase ):
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments