@@ -156,32 +156,31 @@ def setUp(self):
156156        self .test_script .write (textwrap .dedent (""" 
157157            def simple_function(): 
158158                sum(range(1000)) 
159-                  
159+ 
160160            if __name__ == "__main__": 
161161                simple_function() 
162162        """ ))
163163        self .test_script .close ()
164-          
164+ 
165165    def  tearDown (self ):
166166        os .unlink (self .test_script .name )
167-      
167+ 
168168    def  test_sort (self ):
169169        rc , out , err  =  assert_python_failure ('-m' , 'cProfile' , '-s' , 'demo' )
170170        self .assertGreater (rc , 0 )
171171        self .assertIn (b"option -s: invalid choice: 'demo'" , err )
172-      
172+ 
173173    def  test_valid_sort_options (self ):
174174        for  sort_opt  in  ['calls' , 'cumulative' , 'cumtime' , 'filename' ,
175175                         'ncalls' , 'pcalls' , 'line' , 'name' , 'nfl' ,
176176                         'stdname' , 'time' , 'tottime' ]:
177177            rc , out , err  =  assert_python_ok ('-m' , 'cProfile' , '-s' , sort_opt , self .test_script .name )
178178            self .assertEqual (rc , 0 )
179179            self .assertIn (b"function calls" , out )
180-      
180+ 
181181    def  test_outfile (self ):
182182        with  tempfile .NamedTemporaryFile (suffix = '.prof' , delete = False ) as  outfile :
183183            outfile_name  =  outfile .name 
184-         
185184        try :
186185            rc , out , err  =  assert_python_ok ('-m' , 'cProfile' , '-o' , outfile_name , self .test_script .name )
187186            self .assertEqual (rc , 0 )
@@ -190,34 +189,34 @@ def test_outfile(self):
190189        finally :
191190            if  os .path .exists (outfile_name ):
192191                os .unlink (outfile_name )
193-      
192+ 
194193    def  test_no_arguments (self ):
195194        rc , out , err  =  assert_python_failure ('-m' , 'cProfile' )
196195        self .assertGreater (rc , 0 )
197-      
196+ 
198197    def  test_help_option (self ):
199198        rc , out , err  =  assert_python_ok ('-m' , 'cProfile' , '--help' )
200199        self .assertEqual (rc , 0 )
201200        self .assertIn (b"Usage:" , out )
202-      
201+ 
203202    def  test_version_output (self ):
204203        rc , out , err  =  assert_python_ok ('-m' , 'cProfile' , self .test_script .name )
205204        self .assertEqual (rc , 0 )
206205        import  os 
207206        self .assertIn (os .path .basename (self .test_script .name ).encode (), out )
208-      
207+ 
209208    def  test_run_command_line_module (self ):
210209        rc , out , err  =  assert_python_ok ('-m' , 'cProfile' , '-m' , 'timeit' , '-n' , '1' , 'pass' )
211210        self .assertEqual (rc , 0 )
212211        self .assertIn (b"function calls" , out )
213-      
212+ 
214213    def  test_profile_script_importing_main (self ):
215214        with  tempfile .NamedTemporaryFile ("w+" , suffix = '.py' , delete = False ) as  f :
216215            f .write (textwrap .dedent ("""\  
217216
218217                    x = 1 + 1 
219218                    return x 
220-                  
219+ 
221220                if __name__ == "__main__": 
222221                    test_func() 
223222                """ ))
@@ -229,31 +228,31 @@ def test_func():
229228                self .assertIn (b"test_func" , out )
230229            finally :
231230                os .unlink (f .name )
232-      
231+ 
233232    def  test_output_format (self ):
234233        rc , out , err  =  assert_python_ok ('-m' , 'cProfile' , self .test_script .name )
235234        self .assertEqual (rc , 0 )
236-          
235+ 
237236        output  =  out .decode ('utf-8' )
238-          
237+ 
239238        self .assertRegex (output , r'\d+ function calls in \d+\.\d+ seconds' )
240-          
239+ 
241240        self .assertIn ('Ordered by:' , output )
242-          
241+ 
243242        self .assertIn ('ncalls' , output )
244243        self .assertIn ('tottime' , output )
245244        self .assertIn ('percall' , output )
246245        self .assertIn ('cumtime' , output )
247246        self .assertIn ('filename:lineno(function)' , output )
248-          
247+ 
249248        self .assertIn ('simple_function' , output )
250-          
249+ 
251250    def  test_different_sort_outputs (self ):
252251        rc1 , out1 , _  =  assert_python_ok ('-m' , 'cProfile' , '-s' , 'time' , self .test_script .name )
253252        rc2 , out2 , _  =  assert_python_ok ('-m' , 'cProfile' , '-s' , 'cumulative' , self .test_script .name )
254-          
253+ 
255254        self .assertNotEqual (out1 , out2 )
256-          
255+ 
257256        self .assertIn (b'simple_function' , out1 )
258257        self .assertIn (b'simple_function' , out2 )
259258
0 commit comments