[py-dev] New resource API feedback
flub at devork.be
Wed Aug 15 00:41:11 CEST 2012
I've started experimenting a bit more with the new resource api in
pytest-django, I haven't got very far yet but do have already some
feedback and questions.
Firstly my main issue, I don't know how to inspect the marks on the
function/item in a function-scoped setup. Looking at the code the
only thing I could find was TestContext._resource.keywords and
TestContext._resource.applymarker(). The latter which has an explicit
comment saying it is unavailable on purpose. The former almost
exposed as TestContext.keywords but commented out. So how do you use
markers? This should probably be documented as well.
Secondly the docs should probably show how to do teardown in an @setup
function. I think it would be nice to show an example of scope and
teardown before going into the global resource example. Related to
this TestContext.addfinalizer() is not documented in the TestContext
API docs. Probably because autodoc doesn't pick it up. Maybe simply
merging TestContextRequest into TestContext is enough?
TestContextSetup would not need any changes to keep it's behaviour in
Next something I have mentioned before, marking a pytest_funcarg__foo
function with @factory seems to sill give an incomprehensible error.
Personally I think it should be possible and "consume" the funcarg
just like @setup consumes e.g. setup_module(), but if I'm alone in
that a clearer error would be good improvement.
Another thing which surprised me was that @pytest.setup() needs to be
called in order to have any effect. Not calling the decorator will
simply ignore the setup function, I expected it to treat it as a
More information about the Pytest-dev