Actions

icon Post
text/html Subscribe
text/html Unsubscribe

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [qmtest] Specifying arguments in derived test classes


  • To: Vladimir Prus <ghost@xxxxxxxxx>, "qmtest@xxxxxxxxxxxxxxxx" <qmtest@xxxxxxxxxxxxxxxx>
  • Subject: Re: [qmtest] Specifying arguments in derived test classes
  • From: Mark Mitchell <mark@xxxxxxxxxxxxxxxx>
  • Date: Mon, 15 Apr 2002 08:08:18 -0700



--On Friday, April 12, 2002 05:19:05 PM +0400 Vladimir Prus <ghost@xxxxxxxxx> wrote:


Hi,
I'm trying to create a test class that would derive from python.ExecTest
and  change it a little. In particular, I want to get rid of 'expession'
argument.  I'm trying the following:

class Test(python.ExecTest):

    arguments = [
        qm.fields.TextField(
            name="source",
            title="Python Source Code",
            description="""The source code.

            This code may contain class definitions, function
            definitions, statements, and so forth.  If this code
            throws an uncaught exception, the test will fail.""",
            verbatim="true",
            multiline="true",
            default_value="pass"
            )
        ]

    def __init__(self, **properties):

        apply(python.ExecTest.__init__, (self,), properties)
        self.expression = None

    def Run(self, context, result):
	# Not relevant here

However, I get a test class with three arguments: two defined in
python.ExecTest and one defined in my class. How can I accomplish what I
want?

There's no easy way to do this.

The plan is to add "computed arguments" which would solve this problem.
For the time being, you have no real choice but to create a whole new
class.

(At one point, it was possible to do approximately what you wanted;
each class could completely override "arguments".  We decided this was
a bad design since that meant that derived classes had to explicitly
list the arguments from the base classes, and there was no guarantee
that the "is-a" relationship would be preserved.)

--
Mark Mitchell                   mark@xxxxxxxxxxxxxxxx
CodeSourcery, LLC               http://www.codesourcery.com