[twill] bug with back and reload

Tommi Virtanen tv at inoi.fi
Tue Oct 25 01:35:57 PDT 2005


Hi. It seems "back" does not really set the current URL back to the
previous one, atleast not in a way "reload" would understand.
The following patch makes the test script demonstrate the bug.
If you replace "reload" with "go /", it works, with reload it doesn't.

--- old-trunk/test/test_twill.twill     2005-10-03 18:14:36.000000000 +0300
+++ new-trunk/test/test_twill.twill     2005-10-25 10:09:28.000000000 +0300
@@ -70,6 +70,12 @@
 code 403

 back
+find "this is visit #2"
+# this must reload the / resource, not /restricted
+reload
+code 200
+find "this is visit #2"
+
 go ./login

 # test formclear


This fixes all the symptoms, though it isn't the cleanest thing to do.

--- old-trunk/twill/commands.py 2005-10-03 21:48:29.000000000 +0300
+++ new-trunk/twill/commands.py 2005-10-25 10:18:12.000000000 +0300
@@ -110,7 +110,7 @@
         print '==> at', self.get_url()

     def reload(self):
-        self._last_result = journey(self._browser.reload)
+        self._last_result = journey(self._browser.open, self.get_url())
         print '==> reloaded'

     def back(self):


Here's a patch that adds an assertion that triggers when the current
url is corrupted. Maybe it can show the way to a proper fix.

--- old-trunk/twill/commands.py 2005-10-03 21:48:29.000000000 +0300
+++ new-trunk/twill/commands.py 2005-10-25 10:13:36.000000000 +0300
@@ -126,6 +126,10 @@
             self._last_result = None

         if self._last_result:
+            assert self.get_url() ==
self._browser.request.get_full_url(), \
+                   'Confused about current URL: %r != %r' % (
+                self.get_url(),
+                self._browser.request.get_full_url())
             print '==> back to', self.get_url()
         else:
             print '==> no previous URL; ignoring.'



PS. please allow non-subscribers to send mail to the list, the
    current behaviour is frigging annoying.

-- 
Inoi Oy, Tykistökatu 4 D (4. krs), FIN-20520 Turku, Finland
http://www.inoi.fi/
Mobile +358 40 762 5656



More information about the twill mailing list