2009/8/18 Filip Gruszczyński <[email protected]>:
>
>> I don't think I understand your proposal. An example would be
>> extremely helpful here. Under your proposal, what would my new
>> tests.py look like? How would I invoke a single test? A single test
>> case? A single suite?
>
> That's not exactly my proposal. Proposal was reported by someone else
> and the ticket was accepted, so I hoped I could sit down to it. It
> seemed confined and would allow to get a very close look at the test
> framework, so I would like to try and code it.
>
> That it must be backward compatible is very clear to me. The example
> would look like this:
>
> class TestCase1(TestCase):
>
> ..
>
> class TestCase2(TestCase):
>
> ..
>
> class TestSuite1(TestSuite):
> case1 = TestCase1
> case2 = TestCase2
>
> Now you can run:
> ./manage.py test app.TestCase1
>
> or if you wish
> ./manage.py test app.TestSuite1
>
> and TestSuite1 would run all test cases, that were specified in test suite,
Ok - your proposal now makes a lot more sense. However, I think you're
stepping outside the original request of the ticket.
The idea behind suites is to provide a way to group tests that doesn't
necessarily correlate to your TestCase structure. For example, you
could have:
class WidgetTestCase(TestCase):
def testW1(self):
....
def testW2(self):
....
class GadgetTestCase(TestCase):
def testG1(self):
....
def testG2(self):
....
def suiteA():
suite = unittest.TestSuite()
suite.addTest(WidgetTestCase('testW1'))
suite.addTest(WidgetTestCase('testW2'))
suite.addTest(GadgetTestCase('testG2'))
return suite
def suiteB():
suite = unittest.TestSuite()
suite.addTest(WidgetTestCase('testW2'))
suite.addTest(GadgetTestCase('testG1'))
suite.addTest(GadgetTestCase('testG2'))
return suite
Here we have defined 2 test suites, from overlapping subsets of the
underlying test cases.
Ticket #11627 is asking for a way to invoke individual test suites as
a command line option to test - that is, in addition to the following:
./manage.py test
./manage.py test app
./manage.py test app.WidgetTestCase
./manage.py test app.WidgetTestCase.testW1
you should also be able to invoke
./manage.py test app.suiteA
Your proposal covers this issue of invoking test suites. This should
be a fairly simple issue to resolve - it's just a matter of modifying
the test runner to look for a suite with the appropriate name before
it goes the process of discovering TestCase instances and building a
default suite.
However, in addition to this lookup problem, you also seem to be
proposing a new technique for defining suites. While I'm all in favor
of proposals that make it easier to construct test suites, I'm not
sure your proposal is that strong - for instance, unless I'm mistaken,
the simple example I gave (which is a completely legal suite) couldn't
be composed using your proposed syntax.
If you want to pursue this idea of making it easier to define suites,
please open a second ticket - the two ideas don't need to get mixed
together.
> As I understand the need (once again, I am not the reporter, I am
> trying to understand, how it should work too) this would allow you to
> group some tests from an app and instead of calling all the tests from
> an app or specify them explictly, you group them in a suite and run
> just the suite. This might be useful, if there are plenty of tests in
> an app and you would like to run only a subset of them, which still
> might be significantly large. Then you build a suite and you can
> specify only this suite. But maybe Alex had something different in
> mind - if he could specify it better, I'd love to conform to this. At
> this point I am not very into any design decisions, not with mu
> current knowledge of Django. I'd would like to dive into the code base
> and learn. This seemed as a good start.
This is quite a good pick for a "first bug". It's fairly small, but
hits on some interesting parts of the Django test framework.
Just make sure you solve the original problem - don't get carried away
trying to solve a problem that is outside the original problem
definition.
Yours
Russ Magee %-)
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/django-developers?hl=en
-~----------~----~----~----~------~----~------~--~---