Edgewall Software
Modify

Opened 16 years ago

Closed 16 years ago

#7472 closed defect (fixed)

better_twill treats browser as global

Reported by: felix.schwarz@… 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)

even_better_twill.patch (4.4 KB ) - added by felix.schwarz@… 16 years ago.
This patch fixes the problem (diffed against 0.11.1)
even_better_twill.2.patch (5.3 KB ) - added by felix.schwarz@… 16 years ago.
updated patch for r7491

Download all attachments as: .zip

Change History (7)

by felix.schwarz@…, 16 years ago

Attachment: even_better_twill.patch added

This patch fixes the problem (diffed against 0.11.1)

comment:1 by Eli Carter, 16 years ago

Owner: set to Eli Carter

by felix.schwarz@…, 16 years ago

Attachment: even_better_twill.2.patch added

updated patch for r7491

in reply to:  description comment:2 by Remy Blank, 16 years ago

Milestone: 0.12
Owner: changed from Eli Carter to Remy Blank

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 Remy Blank, 16 years ago

Resolution: fixed
Status: newclosed

Yes, it does. Fixed in trunk in [7606].

comment:4 by ebray, 16 years ago

Resolution: fixed
Status: closedreopened

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 Remy Blank, 16 years ago

Resolution: fixed
Status: reopenedclosed

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.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Remy Blank.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Remy Blank to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.