finalized docs and funcarg attributes, i think
--HG-- branch : trunk
This commit is contained in:
2
py/test/dist/testing/test_nodemanage.py
vendored
2
py/test/dist/testing/test_nodemanage.py
vendored
@@ -3,7 +3,7 @@ from py.__.test.dist.nodemanage import NodeManager
|
||||
|
||||
class pytest_funcarg__mysetup:
|
||||
def __init__(self, request):
|
||||
basetemp = request.config.ensuretemp(request.getfspath().purebasename)
|
||||
basetemp = request.maketempdir()
|
||||
basetemp = basetemp.mkdir(request.function.__name__)
|
||||
self.source = basetemp.mkdir("source")
|
||||
self.dest = basetemp.mkdir("dest")
|
||||
|
||||
@@ -403,6 +403,7 @@ class FuncargRequest:
|
||||
self.argname = argname
|
||||
self.function = pyfuncitem.obj
|
||||
self.config = pyfuncitem.config
|
||||
self.fspath = pyfuncitem.fspath
|
||||
self._plugins = self._getplugins()
|
||||
self._methods = self.config.pluginmanager.listattr(
|
||||
plugins=self._plugins,
|
||||
@@ -431,8 +432,12 @@ class FuncargRequest:
|
||||
def addfinalizer(self, finalizer):
|
||||
self._pyfuncitem.addfinalizer(finalizer)
|
||||
|
||||
def getfspath(self):
|
||||
return self._pyfuncitem.fspath
|
||||
def maketempdir(self):
|
||||
basetemp = self.config.getbasetemp()
|
||||
tmp = py.path.local.make_numbered_dir(
|
||||
prefix=self.function.__name__ + "_",
|
||||
keep=0, rootdir=basetemp)
|
||||
return tmp
|
||||
|
||||
def _raiselookupfailed(self):
|
||||
available = []
|
||||
@@ -447,4 +452,5 @@ class FuncargRequest:
|
||||
msg += "\n available funcargs: %s" %(", ".join(available),)
|
||||
raise LookupError(msg)
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -72,9 +72,9 @@ class TestRequest:
|
||||
req = item.getrequest("other")
|
||||
assert req.argname == "other"
|
||||
assert req.function == item.obj
|
||||
assert req.funcname == "test_func"
|
||||
assert req.function.__name__ == "test_func"
|
||||
assert req.config == item.config
|
||||
assert repr(req).find(req.funcname) != -1
|
||||
assert repr(req).find(req.function.__name__) != -1
|
||||
|
||||
def test_request_contains_funcargs_methods(self, testdir):
|
||||
modcol = testdir.getmodulecol("""
|
||||
@@ -114,8 +114,17 @@ class TestRequest:
|
||||
req.addfinalizer(l.pop)
|
||||
item.teardown()
|
||||
|
||||
def test_request_maketemp(self, testdir):
|
||||
item = testdir.getitem("def test_func(): pass")
|
||||
req = item.getrequest("xxx")
|
||||
tmpdir = req.maketempdir()
|
||||
tmpdir2 = req.maketempdir()
|
||||
assert tmpdir != tmpdir2
|
||||
assert tmpdir.basename.startswith("test_func")
|
||||
assert tmpdir2.basename.startswith("test_func")
|
||||
|
||||
def test_request_getmodulepath(self, testdir):
|
||||
modcol = testdir.getmodulecol("def test_somefunc(): pass")
|
||||
item, = testdir.genitems([modcol])
|
||||
req = item.getrequest("hello")
|
||||
assert req.getfspath() == modcol.fspath
|
||||
assert req.fspath == modcol.fspath
|
||||
|
||||
Reference in New Issue
Block a user