* refined funcarg docs and CHANGELOG

* fixed funcarg setup and error-raising issue

--HG--
branch : 1.0.x
This commit is contained in:
holger krekel
2009-07-05 14:22:01 +02:00
parent cd5ffcc605
commit 183af95526
5 changed files with 88 additions and 75 deletions

View File

@@ -165,7 +165,7 @@ class FuncargRequest:
line = "%s:%s" %(fspath, lineno)
msg = "funcargument %r not found for: %s" %(argname, line)
msg += "\n available funcargs: %s" %(", ".join(available),)
raise LookupError(msg)
raise self.Error(msg)

View File

@@ -254,5 +254,5 @@ class SetupState(object):
break
self._pop_and_teardown()
for col in needed_collectors[len(self.stack):]:
col.setup()
self.stack.append(col)
col.setup()

View File

@@ -152,6 +152,7 @@ class TestRequest:
def test_func(something): pass
""")
req = funcargs.FuncargRequest(item)
py.test.raises(req.Error, req.getfuncargvalue, "notexists")
val = req.getfuncargvalue("something")
assert val == 1
val = req.getfuncargvalue("something")
@@ -181,6 +182,21 @@ class TestRequest:
print ss.stack
assert teardownlist == [1]
def test_request_addfinalizer_partial_setup_failure(self, testdir):
p = testdir.makepyfile("""
l = []
def pytest_funcarg__something(request):
request.addfinalizer(lambda: l.append(None))
def test_func(something, missingarg):
pass
def test_second():
assert len(l) == 1
""")
result = testdir.runpytest(p)
assert result.stdout.fnmatch_lines([
"*1 failed*1 passed*"
])
def test_request_getmodulepath(self, testdir):
modcol = testdir.getmodulecol("def test_somefunc(): pass")
item, = testdir.genitems([modcol])