Title: unittest: _top_level_dir is incorrectly persisted between calls to different load_test methods
Type: behavior Stage: patch review
Components: Library (Lib) Versions: Python 3.9, Python 3.8, Python 3.7, Python 2.7
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: ZackerySpytz, igorsobreira, michael.foord, r.david.murray
Priority: normal Keywords: patch

Created on 2012-06-06 01:20 by r.david.murray, last changed 2019-08-13 12:18 by vstinner.

File name Uploaded Description Edit
restore_top_level_dir.patch igorsobreira, 2012-07-19 22:56 review
restore_top_level_dir_to_previous_value.patch igorsobreira, 2012-07-20 18:35 review
Pull Requests
URL Status Linked Edit
PR 15242 open ZackerySpytz, 2019-08-13 01:10
Messages (5)
msg162387 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2012-06-06 01:20
During the execution of the load tests protocol, the loader instance will set its _top_level_dir attribute, and this will persist if the loader is passed on to another load_tests method.  If that method does not specify a top_level_dir in a discovery call, the wrong top_level_dir may be used, and loading will fail.

You can reproduce this by having two test *packages* with a load_tests method that calls discover in their, and specify both package names to the unittest CLI.
msg165887 - (view) Author: Igor Sobreira (igorsobreira) Date: 2012-07-19 22:56
Hello. I've attached a patch to cleanup self._top_level_dir in the end of discover(). Is that the expected behavior or I'm on the wrong track?
msg165954 - (view) Author: Igor Sobreira (igorsobreira) Date: 2012-07-20 17:38
My previous patch is incorrect, talking to voidspace on irc self._top_leve_dir should be reverted to it's previous value

"so when discover is called the original value should be stored, then discovery done, and then the original restored"

I'll work on this one.

He also pointed out that this bugfix should be backported to 2.7 and 3.2
msg165966 - (view) Author: Igor Sobreira (igorsobreira) Date: 2012-07-20 18:35
Updated patch to restore previous value of ._top_level_dir on discover() done. And added a unit test.
msg348649 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-07-29 12:01
This issue is not newcomer friendly, I remove the easy keyword.
Date User Action Args
2019-08-13 12:18:54vstinnersetnosy: - vstinner
2019-08-13 01:12:14ZackerySpytzsetnosy: + ZackerySpytz

versions: + Python 3.7, Python 3.8, Python 3.9, - Python 3.2, Python 3.3
2019-08-13 01:10:28ZackerySpytzsetstage: needs patch -> patch review
pull_requests: + pull_request14963
2019-07-29 12:01:51vstinnersetkeywords: - easy
nosy: + vstinner
messages: + msg348649

2012-07-20 18:35:19igorsobreirasetfiles: + restore_top_level_dir_to_previous_value.patch

messages: + msg165966
2012-07-20 17:38:30igorsobreirasetmessages: + msg165954
2012-07-19 22:56:56igorsobreirasetfiles: + restore_top_level_dir.patch

nosy: + igorsobreira
messages: + msg165887

keywords: + patch
2012-06-06 01:20:42r.david.murraycreate