zopefoundation / zope.testbrowser

Programmable browser for functional black-box tests
Other
21 stars 16 forks source link

getLink now tests regexes using .match, not .search #82

Open cjwatson opened 5 years ago

cjwatson commented 5 years ago

(I see several open issues about compatibility with the old mechanize-based test browser, so I hope this sort of thing is welcome.)

I'm in the process of migrating a large project (Launchpad) from old versions of zope.testbrowser to version 5.x. One thorn in my side has been that in several places we do something like this:

    edit_status_url = re.compile(r'1.0/\+bug/[0-9]+/\+editstatus')
    browser.getLink(url=edit_status_url).click()

This worked with mechanize because regexes were tested using .search. However, zope.testbrowser now tests them using .match, so the above code has to be more like this:

    edit_status_url = re.compile(r'.*/1.0/\+bug/[0-9]+/\+editstatus')
    browser.getLink(url=edit_status_url).click()

I don't suppose it would be possible to go back to 4.x-compatible behaviour here?

mgedmin commented 5 years ago

I would be inclined to view such a PR favourably. (I might regret that later, if it turns out users are already relying on the new semantics.)