Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

unittest keeps references to test cases alive #61736

Open
ezio-melotti opened this issue Mar 23, 2013 · 3 comments
Open

unittest keeps references to test cases alive #61736

ezio-melotti opened this issue Mar 23, 2013 · 3 comments
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@ezio-melotti
Copy link
Member

BPO 17534
Nosy @pitrou, @ezio-melotti, @voidspace, @serhiy-storchaka

Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

Show more details

GitHub fields:

assignee = None
closed_at = None
created_at = <Date 2013-03-23.22:06:48.739>
labels = ['type-bug', 'library']
title = 'unittest keeps references to test cases alive'
updated_at = <Date 2018-12-11.23:25:10.908>
user = 'https://github.com/ezio-melotti'

bugs.python.org fields:

activity = <Date 2018-12-11.23:25:10.908>
actor = 'serhiy.storchaka'
assignee = 'none'
closed = False
closed_date = None
closer = None
components = ['Library (Lib)']
creation = <Date 2013-03-23.22:06:48.739>
creator = 'ezio.melotti'
dependencies = []
files = []
hgrepos = []
issue_num = 17534
keywords = []
message_count = 3.0
messages = ['185100', '185195', '331666']
nosy_count = 5.0
nosy_names = ['pitrou', 'ezio.melotti', 'michael.foord', 'tshepang', 'serhiy.storchaka']
pr_nums = []
priority = 'normal'
resolution = None
stage = 'needs patch'
status = 'pending'
superseder = None
type = 'behavior'
url = 'https://bugs.python.org/issue17534'
versions = ['Python 2.7', 'Python 3.3', 'Python 3.4']

@ezio-melotti
Copy link
Member Author

After the subtests commit (5c09e1c57200/bpo-16997), test_queue started showing the following warning:
Warning -- threading._dangling was modified by test_queue
1 test altered the execution environment:
test_queue

The warning was caused by the fact that the TestCase subclasses in test_queue kept references to the thread, but before 5c09e1c57200 these subclasses (and hence the references to the thread) were destroyed before the regrtest check for threading._dangling, whereas now they are kept alive (due to Lib/unittest/case.py:72, that adds a reference to the TestCase even in case of success). I now fixed the warning in test_queue (1747e50fca55), however unittest should probably avoid keeping alive TestCases when they are not needed anymore.

See also bpo-9815.

(Thanks to Antoine for the help while I was debugging the issue.)

@ezio-melotti ezio-melotti added stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels Mar 23, 2013
@voidspace
Copy link
Contributor

bpo-11798 is somewhat related.

@serhiy-storchaka
Copy link
Member

Does this issue still relevant?

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
Projects
Status: No status
Development

No branches or pull requests

3 participants