[qmtest] adding context variables in a target extension class
Mark Mitchell
mark at codesourcery.com
Thu Nov 20 03:04:31 UTC 2003
On Wed, 2003-11-19 at 14:41, Steve Byan wrote:
> I'd like to add some test context variables in a target extension
> class. Unless I've missing something (quite possible), the only obvious
> place where a target extension class can get its paws on the context is
> in the RunTest method. So I imagine something like this:
>
> def RunTest(self, descriptor, context):
> properties = { "TARGET_HOSTNAME" : "minigolf.egenera.com" }
> context = ContextWrapper(context, properties)
> Target.RunTest(self, descriptor, context)
>
>
> It seems a little heavyweight to be constructing a ContextWrapper in
> the RunTest method in the MyTarget class and then constructing yet
> another ContextWrapper on the ContextWrapper in the RunTest method in
> the base Target class. Have I missed something - isn't there a way to
> add to the context in the __init__ or Start methods?
In the CVS version of QMTest, there is no ContextWrapper class any
more. Instead, Context has taken the place of both Context and
ContextWrapper. However, the basic idea you're using would still work
in the same way.
There's no way to set the default set of context properties other than
the technique you've discovered. It's not really all that heavyweight;
I'd be surprised if you could measure any difference when
creating/destroying the extra Context objects.
I think that you wouldn't want to have a single Target change the global
context because that would affect tests running on other targets as
well.
--
Mark Mitchell <mark at codesourcery.com>
CodeSourcery, LLC
More information about the qmtest
mailing list