[TIP] unittest2/nose2: plugin interaction or overrides or ... ?
fuzzyman at voidspace.org.uk
Thu Sep 2 10:29:14 PDT 2010
On 31/08/2010 14:48, jason pellerin wrote:
>> Let me know if I can change anything in moduleloading (I don't like the name
>> and may change it - suggestions welcomed) to make it more reusable.
> A couple of things would help:
> - break out the check for generatorness and the extraction of setup
> and teardown attributes into methods I can override. (eg isGenerator =
> self.isGenerator(obj) instead of isGenerator = getattr(obj,
> 'testGenerator', False)
Done. Both the Functions and the Generators plugins have isGenerator
> - in testsFromGenerator, either make testsFromGeneator a method itself
> and have it call an overridable method instead of enumerate() for
> iterating the generator, or allow testsFromGenerator to take a
> callback that is called instead of enumerate.
> The reason for the latter change is that nose expects generator tests'
> yields to look like this:
> yield callable_or_name, arg, arg, arg
> and I'd like to support that as well as unittest2's:
> yield callable, (arg, arg, arg)
> to do that cleanly, this line:
> for index, (func, args) in enumerate(generator):
> needs to change (or nose needs to wrap each generator func it sees in
> another generator that munges the output, but I think that would mess
> up user's tracebacks so I'd rather avoid it if possible).
The testsFromGenerator function takes an unpack argument. Both Functions
and Generators have an unpack class attribute 'unpack' that is passed
in. You can override this in a subclass.
Let me know if you need any further changes or I screwed something up.
All the best,
READ CAREFULLY. By accepting and reading this email you agree, on behalf of your employer, to release me from all obligations and waivers arising from any and all NON-NEGOTIATED agreements, licenses, terms-of-service, shrinkwrap, clickwrap, browsewrap, confidentiality, non-disclosure, non-compete and acceptable use policies (”BOGUS AGREEMENTS”) that I have entered into with your employer, its partners, licensors, agents and assigns, in perpetuity, without prejudice to my ongoing rights and privileges. You further represent that you have the authority to release me from any BOGUS AGREEMENTS on behalf of your employer.
More information about the testing-in-python