checking that option contains glob characters before calling fnmatch
requested during code review --HG-- branch : python-classes-glob
This commit is contained in:
parent
b928928942
commit
0b620c304b
|
@ -322,7 +322,11 @@ class PyCollector(PyobjMixin, pytest.Collector):
|
||||||
for option in self.config.getini(option_name):
|
for option in self.config.getini(option_name):
|
||||||
if name.startswith(option):
|
if name.startswith(option):
|
||||||
return True
|
return True
|
||||||
elif fnmatch.fnmatch(name, option):
|
# check that name looks like a glob-string before calling fnmatch
|
||||||
|
# because this is called for every name in each collected module,
|
||||||
|
# and fnmatch is somewhat expensive to call
|
||||||
|
elif ('*' in option or '?' in option or '[' in option) and \
|
||||||
|
fnmatch.fnmatch(name, option):
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue