#26198: partition_suite() removing non duplicate tests
-----------------------------------+--------------------
     Reporter:  lukeaus            |      Owner:  nobody
         Type:  Bug                |     Status:  new
    Component:  Testing framework  |    Version:  1.8
     Severity:  Normal             |   Keywords:
 Triage Stage:  Unreviewed         |  Has patch:  0
Easy pickings:  0                  |      UI/UX:  0
-----------------------------------+--------------------
 In django 1.8 partition_suite() in django.test.runner is only including my
 behave tests from the first app.

 e.g. ./manage.py test foo bar baz
 will test all unit tests for apps foo, bar and baz, but will only test
 behave tests for app foo.

 I am using django-behave==0.1.5 and behave==1.2.5 with django==1.8.9

 This setup was working fine - tested in django==1.7.11 and was not a
 problem - upgrading to 1.8 is when the problem began.

 All tests appear to be passed correctly to reorder_suite() but in
 partition_suite() only behave tests of the first app listed are being
 added to be tested.

 In the 'django.tests.runner' module this appears to be due to
 reorder_suite() using an OrderedSet and subsequent
 '<django_behave.runner.DjangoBehaveTestCase testMethod=runTest>' objects
 not getting added to this set in partition_suite(). To confirm - the
 subsequent objects that should be added do have different object IDs and
 are in fact different tests.

 {{{
 #!div style="font-size: 80%"
   {{{#!python
 def partition_suite(suite, classes, bins, reverse=False):
     suite_class = type(suite)
     if reverse:
         suite = reversed(tuple(suite))
     for test in suite:
         if isinstance(test, suite_class):
             partition_suite(test, classes, bins, reverse=reverse)
         else:
             for i in range(len(classes)):
                 if isinstance(test, classes[i]):
                     bins[i].add(test)  # subsequent behave test objects
 not being added here
                     break
             else:
                 bins[-1].add(test)
   }}}
 }}}

 Looking at this commit:
 
https://github.com/django/django/commit/2ca0870b672413cf5bc6e441bda58839f902f5b0
 In partition_suite() I changed:
 {{{
 #!div style="font-size: 80%"
   {{{#!python
     bins = [OrderedSet() for i in range(class_count + 1)]
   }}}
 }}}
 back to
 {{{
 #!div style="font-size: 80%"
   {{{#!python
     bins = [suite_class() for i in range(class_count + 1)]
   }}}
 }}}

 and I changed
 {{{
 #!div style="font-size: 80%"
   {{{#!python
     bins[i].add(test)
   }}}
 }}}

 to
 {{{
 #!div style="font-size: 80%"
   {{{#!python
     bins[i].addTest(test)
   }}}
 }}}

 I retested using my test suite for my project and all the tests ran as
 expected.

 Not sure what the further implications of changing this are with regards
 to preventing duplicated tests from being added to the suite.

 Thanks

--
Ticket URL: <https://code.djangoproject.com/ticket/26198>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/050.854697bcdb92cd5784e50a89f9147b7a%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to