Opened 8 years ago

Closed 8 years ago

#26942 closed New feature (fixed)

support subtests when running tests in parallel

Reported by: Chris Jerdonek Owned by: Chris Jerdonek
Component: Testing framework Version: 1.9
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

When I try running unit tests using the --parallel option described here, I get the following error:

NotImplementedError: subtests aren't supported at this time

Here is where this message originates in the code. Was this planned for a future version? Thanks.

Change History (10)

comment:1 by Aymeric Augustin, 8 years ago

I didn't implement support for subtests when I wrote the parallel test runner because Django doesn't use them, the primary use case was Django's own test suite, and IIRC it wasn't entirely obvious how to deal with them. A patch implementing that method would certainly be appreciated.

comment:2 by Tim Graham, 8 years ago

Component: UncategorizedTesting framework
Triage Stage: UnreviewedAccepted
Type: UncategorizedNew feature

comment:3 by Chris Jerdonek, 8 years ago

Owner: changed from nobody to Chris Jerdonek
Status: newassigned

comment:4 by Chris Jerdonek, 8 years ago

I got a proof of concept for this working in a branch on GitHub here.

The code change looks like the following:

def addSubTest(self, test, subtest, err):
    # Following unittest.TestResult.addSubTest()'s implementation in
    # Python 3.5, we don't do anything with subtests on success.
    # See here for the Django ticket to support subtests with the
    # --parallel test option:
    # https://code.djangoproject.com/ticket/26942
    if err is not None:
        self.check_picklable(test, err)
        self.events.append(('addSubTest', self.test_index, subtest, err))
        self.stop_if_failfast()

I can work on a regression test, etc, over time.

Last edited 8 years ago by Chris Jerdonek (previous) (diff)

comment:5 by Chris Jerdonek, 8 years ago

Do you have any thoughts or ideas on a good testing approach for this?

It has a few tricky aspects.

At the least, it seems like the tests should test the code paths of (1) a successful and (2) a failing subtest in a somewhat end-to-end fashion. The success case can easily be met simply by including a test containing a subtest (which would suffice assuming the tests are already being run in parallel mode).

But for the failing case, we don't want to don't want to interfere with the test run itself. In my first attempt at programmatically instantiating and running a ParallelTestSuite within a test case, I got the following error (because it was running a parallel test within a parallel test):

  File "/.../lib/python3.5/multiprocessing/process.py", line 103, in start
    'daemonic processes are not allowed to have children'
AssertionError: daemonic processes are not allowed to have children

There is also the question of whether and which of these tests should run even if the tests aren't being run in parallel mode.

Version 0, edited 8 years ago by Chris Jerdonek (next)

comment:6 by Chris Jerdonek, 8 years ago

Has patch: set

I posted a pull request for this here.

comment:7 by Tim Graham, 8 years ago

Patch needs improvement: set

Comments for improvement are on the PR.

comment:8 by Chris Jerdonek, 8 years ago

comment:9 by Chris Jerdonek, 8 years ago

Patch needs improvement: unset

comment:10 by Tim Graham <timograham@…>, 8 years ago

Resolution: fixed
Status: assignedclosed

In 42dcceba:

Fixed #26942 -- Added support for subtests during parallel testing.

Note: See TracTickets for help on using tickets.
Back to Top