django / django/new-features

Parallel Testing Enhancements

Open
#41 15 comments 4 reactions 0 assignees View on GitHub
Dominant language
No language data
Stars
188
Forks
7
PR merge metrics
No merged PRs in 30d

Description

### Code of Conduct

- [x] I agree to follow Django's Code of Conduct

### Feature Description

Introduce a new command-line flag that, when enabled, automatically re-executes any tests that failed due to being non-pickleable in parallel mode on the main thread. This lets developers inspect the actual failures without rerunning the entire test suite or manually re-selecting individual tests.

### Problem

Running tests in parallel is often drastically faster but it comes with the downside that sometimes when the tests fail you cannot see the error message. Which means that if there is any error you either have to run all the tests again (or for a specific app) in a single thread just to see the error message(s). This can lead to often just running all the tests once on a single thread.

### Request or proposal

proposal

### Additional Details

I envision it to work something like this. I am not sure about the exact order of when the failed tests would rerun or if the database should be destroyed and recreated before running the failed tests.

```
python manage.py test --parallel --rerunfailed
Found 300 test(s).
Creating test database for alias 'default'...
Cloning test database for alias 'default'...
Cloning test database for alias 'default'...
Cloning test database for alias 'default'...
.........................................................................F........................................

FAIL: test_was_published_recently_with_future_poll (polls.tests.PollMethodTests)

----------------------------------------------------------------------
Ran 300 test in 8.403s

FAILED (failures=1)

Running failed tests

F

======================================================================
FAIL: test_was_published_recently_with_future_poll (polls.tests.PollMethodTests)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/dev/mysite/polls/tests.py", line 16, in test_was_published_recently_with_future_poll
self.assertIs(future_poll.was_published_recently(), False)
AssertionError: True is not False

----------------------------------------------------------------------
Ran 1 test in 0.003s

FAILED (failures=1)

Destroying test database for alias 'default'...
Destroying test database for alias 'default'...
Destroying test database for alias 'default'...
Destroying test database for alias 'default'...
```

### Implementation Suggestions

_No response_

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.