* refactor plugin support to work directly with
modules, no classes required anymore. * call funcarg hook if defined on class --HG-- branch : trunk
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
"""
|
||||
provide temporary directories to test functions and methods.
|
||||
|
||||
example:
|
||||
|
||||
pytest_plugins = "pytest_tmpdir"
|
||||
@@ -9,13 +11,9 @@ example:
|
||||
"""
|
||||
import py
|
||||
|
||||
class TmpdirPlugin:
|
||||
""" provide temporary directories to test functions and methods.
|
||||
"""
|
||||
|
||||
def pytest_funcarg__tmpdir(self, request):
|
||||
name = request.function.__name__
|
||||
return request.config.mktemp(name, numbered=True)
|
||||
def pytest_funcarg__tmpdir(request):
|
||||
name = request.function.__name__
|
||||
return request.config.mktemp(name, numbered=True)
|
||||
|
||||
# ===============================================================================
|
||||
#
|
||||
@@ -24,13 +22,12 @@ class TmpdirPlugin:
|
||||
# ===============================================================================
|
||||
#
|
||||
def test_generic(plugintester):
|
||||
plugintester.hookcheck(TmpdirPlugin)
|
||||
plugintester.hookcheck()
|
||||
|
||||
def test_funcarg(testdir):
|
||||
from py.__.test.funcargs import FuncargRequest
|
||||
item = testdir.getitem("def test_func(tmpdir): pass")
|
||||
plugin = TmpdirPlugin()
|
||||
p = plugin.pytest_funcarg__tmpdir(FuncargRequest(item, "tmpdir"))
|
||||
p = pytest_funcarg__tmpdir(FuncargRequest(item, "tmpdir"))
|
||||
assert p.check()
|
||||
bn = p.basename.strip("0123456789-")
|
||||
assert bn.endswith("test_func")
|
||||
|
||||
Reference in New Issue
Block a user