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

Created on 2012-06-06 01:20 by r.david.murray, last changed 2012-07-20 18:35 by igorsobreira.

Files
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
Messages (4)
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 __init__.py, 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.
History
Date User Action Args
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