Hi testing people! I'm trying to figure out how I can test a code base that uses an existing dependency injection system. I've run into two problems, and I have solutions for each of them but I think maybe there is a better way, so I'm looking for some advice.
The first problem is how do I override how a test using this injector is called? I think I want to use the pytest_runtest_call hook, but it still tries to invoke the test without the injector. My current solution is to use the experimental hookwrapper mechanism to replace item.obj with a partially bound version, then restore it afterward. The second problem I'm having is the py.test fixture system is trying to resolve arguments that are provided by this other injector. How can I tell it that some of these don't need to be provided? My current solution is to blind py.test with a wrapper function with a *a, **kw signature. I use functools.wraps, so annotations are introspectable for the other injector, and delete the __wrapped__ attribute to prevent py.test from introspecting it. Is there a nicer, and perhaps less blunt, way to influence the funcarg fixture behaviors? I've tried a couple things with the pytest_collection_modifyitems hook, but haven't gotten anything that works yet. Other details to know about this injection system: - we want to build and teardown the injector with each test - we may want to configure the injector differently for some tests (possibly with fixture data from py.test) Thanks, Kai
_______________________________________________ pytest-dev mailing list [email protected] https://mail.python.org/mailman/listinfo/pytest-dev
