File tree Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -34,15 +34,17 @@ def testsuite(pattern=''):
3434        The TestSuite object containing the matching tests. 
3535    ''' 
3636    import  re 
37+     from  os .path  import  dirname 
3738    from  itertools  import  chain 
3839    from  pkg_resources  import  resource_filename 
3940    loader  =  unittest .defaultTestLoader 
4041    thisdir  =  resource_filename (__name__ , '' )
41-     suite_all  =  loader .discover (thisdir )
42-     # shortcut when pattern is not specified 
43-     if  not  pattern :
44-         return  suite_all 
45-     # here we need to filter the suite by pattern 
42+     depth  =  __name__ .count ('.' ) +  1 
43+     topdir  =  thisdir 
44+     for  i  in  range (depth ):
45+         topdir  =  dirname (topdir )
46+     suite_all  =  loader .discover (thisdir , top_level_dir = topdir )
47+     # always filter the suite by pattern to test-cover the selection code. 
4648    suite  =  unittest .TestSuite ()
4749    rx  =  re .compile (pattern )
4850    tcases  =  chain .from_iterable (chain .from_iterable (suite_all ))
@@ -51,6 +53,8 @@ def testsuite(pattern=''):
5153        shortname  =  '.' .join (tcwords [- 2 :])
5254        if  rx .search (shortname ):
5355            suite .addTest (tc )
56+     # verify all tests are found for an empty pattern. 
57+     assert  pattern  or  suite_all .countTestCases () ==  suite .countTestCases ()
5458    return  suite 
5559
5660
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments