Hi Floris,

to be sure i understand your use-case: could you invent 
an API/example that you'd like to see working? 

FYI, i am considering introducing a slightly higher level 
mechanism on top of funcargs, dealing with (parametrizable)
resources.  Something like:

@py.test.mark.resourcefactory(scope="session", argnames=['foo', 'bar'])
def myfactory(request):
    if request.argname == "foo":
        ...
    elif request.argname == "bar":
        ... 

The request object would be what pytest_funcarg__NAME get but
this would allow free naming and have a single factory become
responsible for multiple funcargs and allow to declare scope
reather than having to invoke request.cached_setup().  Instead
of the latter, one could write "request.addfinalizer()" which
would default to the declared scope. 

Happy about any thoughts on this but mainly i mention this
consideration here in case it would fit with your use case. 

best,
holger


On Sat, Aug 07, 2010 at 10:52 +0100, Floris Bruynooghe wrote:
> Hi
> 
> I was talking to ronny on IRC about wanting a generic funcarg hook and
> he asked me to post my use case here as you are still thinking about
> the API for it.  Since there is no generic funcarg hook now this is
> how I currently create the tests:
> 
> 
> def pytest_funcarg__tdata(request):
>     fname = os.path.join(DATADIR, requst.function.__name__+'.ext')
>     with file(fname) as fd:
>         obj = fd.read()
>     return obj
> 
> def test_spam(tdata):
>     assert func_under_test(tdata) == 'foo'
> 
> def test_eggs(tdata):
>     assert func_under_test(tdata) == 'bar'
> 
> 
> Before I started writing it this way I was looking for a generic
> funcarg hook since I think this would have been clearer if I could
> have used "spam" and "eggs" as funcargs and still create the object
> for them from one function rather then having to spell it out for each
> one.  So I'm hoping that in a future version you might add an API to
> do allow something like this.
> 
> -- 
> Debian GNU/Linux -- The Power of Freedom
> www.debian.org | www.gnu.org | www.kernel.org
> _______________________________________________
> py-dev mailing list
> py-dev@codespeak.net
> http://codespeak.net/mailman/listinfo/py-dev
> 

-- 
_______________________________________________
py-dev mailing list
py-dev@codespeak.net
http://codespeak.net/mailman/listinfo/py-dev

Reply via email to