Opened 17 years ago
Closed 17 years ago
#7472 closed defect (fixed)
better_twill treats browser as global
| Reported by: | Owned by: | Remy Blank | |
|---|---|---|---|
| Priority: | low | Milestone: | 0.12 | 
| Component: | general | Version: | 0.11-stable | 
| Severity: | major | Keywords: | |
| Cc: | Branch: | ||
| Release Notes: | |||
| API Changes: | |||
| Internal Changes: | |||
Description
In trac.tests.functional there is better_twill which does some monkey patching to add some much needed functionality to twill.
In line 35 there is this code:
# setup short names to reduce typing # This twill browser (and the tc commands that use it) are essentially # global, and not tied to our test fixture. tc = twill.commands b = twill.get_browser()
The problem is that by calling reset_browser() the browser will be closed and twill creates a new browser. Therefore get_browser would return another browser.
This caused us much trouble when we used trac's functional test infrastructure for our own products (we have a GenericFunctionalTestSuite which we use to enable/disable components and modify trac.ini as necessary) because we have to call reset_browser.
The correct solution is not to assume that twill.get_browser() will always return the same instance. You really should just call twill.get_browser() in every function where you need this instance.
Attachments (2)
Change History (7)
by , 17 years ago
| Attachment: | even_better_twill.patch added | 
|---|
comment:1 by , 17 years ago
| Owner: | set to | 
|---|
comment:2 by , 17 years ago
| Milestone: | → 0.12 | 
|---|---|
| Owner: | changed from to | 
Replying to felix.schwarz@…:
You really should just call twill.get_browser() in every function where you need this instance.
Yes. Except that I'm too lazy to type all those (), so I'll make b a proxy object that gets the browser from twill.get_browser() and forwards all accesses to it. I hope this will work.
comment:3 by , 17 years ago
| Resolution: | → fixed | 
|---|---|
| Status: | new → closed | 
Yes, it does. Fixed in trunk in [7606].
comment:4 by , 17 years ago
| Resolution: | fixed | 
|---|---|
| Status: | closed → reopened | 
Rather than create a new ticket I thought I'd reopen this one since it's just a minor typo.
In r7606 you wrote def __setattr(... instead of def __setattr__(....  It just wasn't caught since none of the code currently sets any attributes on the browser object.
comment:5 by , 17 years ago
| Resolution: | → fixed | 
|---|---|
| Status: | reopened → closed | 
Absolutely correct. Actually, at first I had left out __setattr__ completely. Fixed in [7631].
It's good to have somebody looking over my shoulder. Thanks.



  
This patch fixes the problem (diffed against 0.11.1)