python / python/cpython

unittest: tearDown is not called if asyncSetUp fails

Open
#96,139 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

type-bug
Dominant language
Python
Stars
77.2k
Forks
36k
PR merge metrics
PR metrics pending

Description

In unittest.TestCase, tearDown() is always called if setUp() is successful. It is only not called when setUp() fails. In IsolatedAsyncioTestCase, which is a subclass of TestCase, tearDown() is not called if setUp() is successful, but asyncSetUp() fails. I think is a problem.

Linked PRs
  • gh-99596

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by comparing the unittest.TestCase setup and teardown lifecycle with IsolatedAsyncioTestCase, focusing on what happens when asyncSetUp() fails. Check the work referenced by linked PR gh-99596; done should include teardown after successful setUp() followed by a failed asyncSetUp(), with regression coverage.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
testing-qa
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.