Remove check for "_" prefix on python functions (use python_functions)

(See IRC hpk 2012-11-27 14:56: after the python_functions customization
 was introduced, it makes sense to disregard the preliminary "_" check)
This commit is contained in:
Graham Horler 2012-11-27 16:58:08 +00:00
parent ffb5b8efa1
commit 1d7c71884e
2 changed files with 28 additions and 7 deletions

View File

@ -277,13 +277,12 @@ class PyCollector(PyobjMixin, pytest.Collector):
if name in seen:
continue
seen[name] = True
if name[0] != "_":
res = self.makeitem(name, obj)
if res is None:
continue
if not isinstance(res, list):
res = [res]
l.extend(res)
res = self.makeitem(name, obj)
if res is None:
continue
if not isinstance(res, list):
res = [res]
l.extend(res)
l.sort(key=lambda item: item.reportinfo()[:2])
return l

View File

@ -659,6 +659,28 @@ def test_customized_python_discovery(testdir):
"*2 passed*",
])
def test_customized_python_discovery_functions(testdir):
testdir.makeini("""
[pytest]
python_functions=_test
""")
p = testdir.makepyfile("""
def _test_underscore():
pass
""")
result = testdir.runpytest("--collectonly", "-s")
result.stdout.fnmatch_lines([
"*_test_underscore*",
])
result = testdir.runpytest()
assert result.ret == 0
result.stdout.fnmatch_lines([
"*1 passed*",
])
def test_collector_attributes(testdir):
testdir.makeconftest("""
import pytest