This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients serhiy.storchaka, vstinner
Date 2017-09-01.15:11:01
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1504278662.09.0.172151395724.issue31324@psf.upfronthosting.co.za>
In-reply-to
Content
support._match_test() uses a nested loop calling fnmatch.fnmatchcase(). This function creates a temporary regular expression object. The cache of the re module works around the performance... if the length of support.match_tests fits into the cache. But when the list is longer, the function becomes dead slow...

def _match_test(test):
    global match_tests
                                                                                                   
    if match_tests is None:
        return True 
    test_id = test.id()                                                                            
                
    for match_test in match_tests:
        if fnmatch.fnmatchcase(test_id, match_test):                                               
            return True
                                                                                                   
        for name in test_id.split("."):                                                            
            if fnmatch.fnmatchcase(name, match_test):                                              
                return True
    return False

Maybe we should build a giant regex matching test_id at each, but cache the regex since support.match_tests can be modified anytime. I implemented this once, but I lost the code :-)

Currently, it's possible to match 3 things:

* test method name: test_exit
* test class name: SysModuleTest
* full test id: test.test_sys.SysModuleTest.test_exit

It's also possible to use "*" joker character in a test name. I would like to keep these convenient CLI.
History
Date User Action Args
2017-09-01 15:11:02vstinnersetrecipients: + vstinner, serhiy.storchaka
2017-09-01 15:11:02vstinnersetmessageid: <1504278662.09.0.172151395724.issue31324@psf.upfronthosting.co.za>
2017-09-01 15:11:02vstinnerlinkissue31324 messages
2017-09-01 15:11:01vstinnercreate