* 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:
holger krekel
2009-05-18 23:26:16 +02:00
parent 4035fa6326
commit 191d02aef2
33 changed files with 606 additions and 628 deletions

View File

@@ -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")