python: skip nose setup/teardown fixtures if non-callable

Since commit 89f0b5b5a2 cases as in the
added test started to fail, like they do for the standard pytest names
(`setup_module` etc). But the name `setup` in particular is way too
common for us to start taking it over more aggressively, so restore the
previous behavior which required the object to be callable.

Fix #9391.
This commit is contained in:
Ran Benita
2021-12-25 12:03:15 +02:00
parent 443aa0219c
commit 10e21dadee
2 changed files with 25 additions and 0 deletions

View File

@@ -477,3 +477,22 @@ def test_raises(pytester: Pytester) -> None:
"* 1 failed, 2 passed *",
]
)
def test_nose_setup_skipped_if_non_callable(pytester: Pytester) -> None:
"""Regression test for #9391."""
p = pytester.makepyfile(
__init__="",
setup="""
""",
teardown="""
""",
test_it="""
from . import setup, teardown
def test_it():
pass
""",
)
result = pytester.runpytest(p, "-p", "nose")
assert result.ret == 0