Ticket #5 (new defect)

Opened 1 year ago

Last modified 6 months ago

Twill unit tests for the Python example server don't work using Lenny's Twill

Reported by: http://j3h.us/ Assigned to:
Priority: minor Milestone:
Keywords: twill test failure debian lenny Cc:
Project: python-openid OpenID Protocol:
Series: 2.x.x Web Browser:

Description

FE
======================================================================
ERROR: OpenID 1.1 checkid_setup request.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "openid/test/test_examples.py", line 109, in test_checkidv1
    twill.unit.run_test(ti)
  File "/var/lib/python-support/python2.4/twill/unit.py", line 76, in run_test
    test_info.run_script()
  File "openid/test/test_examples.py", line 40, in run_script
    self.script(self)
  File "openid/test/test_examples.py", line 135, in twill_checkidv1
    c.submit("yes")
  File "/var/lib/python-support/python2.4/twill/commands.py", line 354, in submit
    browser.submit(submit_button)
  File "/var/lib/python-support/python2.4/twill/browser.py", line 401, in submit
    raise Exception("no forms on this page!")
Exception: no forms on this page!

======================================================================
FAIL: OpenID 1.1 checkid_setup request.
----------------------------------------------------------------------
Traceback (most recent call last):
  File "openid/test/test_examples.py", line 119, in test_allowed
    twill.unit.run_test(ti)
  File "/var/lib/python-support/python2.4/twill/unit.py", line 76, in run_test
    test_info.run_script()
  File "openid/test/test_examples.py", line 40, in run_script
    self.script(self)
  File "openid/test/test_examples.py", line 176, in twill_allowed
    self.fail(msg)
AssertionError: Traceback (most recent call last):
  File "openid/test/test_examples.py", line 158, in twill_allowed
    c.formvalue(0, 'remember', 'true')
  File "/var/lib/python-support/python2.4/twill/commands.py", line 426, in formvalue
    raise TwillAssertionError("no matching forms!")
TwillAssertionError: no matching forms!

Twill output:==> at http://localhost.localdomain:8080/openidserver?openid.identity=http%3A%2F%2Flocalhost.localdomain%3A8080%2Fid%2Fbob&openid.mode=checkid_setup&openid.return_to=http%3A%2F%2F127.0.0.1%2F__main__.TestServer.test_allowed%2Freturn_to&openid.trust_root=http%3A%2F%2F127.0.0.1%2F__main__.TestServer.test_allowed

Twill errors:
Final page:
<html>
  <head>
    <title>Python OpenID Server Example - Approve OpenID request?</title>
    
  </head>
  <style type="text/css">
      h1 a:link {
          color: black;
          text-decoration: none;
      }
      h1 a:visited {
          color: black;
          text-decoration: none;
      }
      h1 a:hover {
          text-decoration: underline;
      }
      body {
        font-family: verdana,sans-serif;
        width: 50em;
        margin: 1em;
      }
      div {
        padding: .5em;
      }
      table {
        margin: none;
        padding: none;
      }
      .banner {
        padding: none 1em 1em 1em;
        width: 100%;
      }
      .leftbanner {
        text-align: left;
      }
      .rightbanner {
        text-align: right;
        font-size: smaller;
      }
      .error {
        border: 1px solid #ff0000;
        background: #ffaaaa;
        margin: .5em;
      }
      .message {
        border: 1px solid #2233ff;
        background: #eeeeff;
        margin: .5em;
      }
      .form {
        border: 1px solid #777777;
        background: #ddddcc;
        margin: .5em;
        margin-top: 1em;
        padding-bottom: 0em;
      }
      dd {
        margin-bottom: 0.5em;
      }
  </style>
  <body>
    <table class="banner">
      <tr>
        <td class="leftbanner">
          <h1><a href="/">Python OpenID Server Example</a></h1>
        </td>
        <td class="rightbanner">
          You are <a href="/login">not logged in</a>.
        </td>
      </tr>
    </table>
            <div class="message">
                          <p>A site has asked for an identity belonging to
            bob, but you are logged in as None.  To
            log in as bob and approve the login request,
            hit OK below.  The "Remember this decision" checkbox
            applies only to the trust root decision.</p>
            </div>
                        <div class="form">
                          <table>
              <tr><td>Identity:</td><td>http://localhost.localdomain:8080/id/bob</td></tr>
              <tr><td>Trust Root:</td><td>http://127.0.0.1/__main__.TestServer.test_allowed</td></tr>
            </table>
            <p>Allow this authentication to proceed?</p>
            <form method="POST" action="/allow">
              <input type="checkbox" id="remember" name="remember" value="yes"
                  /><label for="remember">Remember this
                  decision</label><br />
              <input type="hidden" name="login_as" value="bob"/>
              <input type="submit" name="yes" value="yes" />
              <input type="submit" name="no" value="no" />
            </form>
            </div>
            
  </body>
</html>


----------------------------------------------------------------------
Ran 2 tests in 0.517s

FAILED (failures=1, errors=1)
$ python
Python 2.4.4 (#2, Jul 21 2007, 11:00:24) 
[GCC 4.1.3 20070718 (prerelease) (Debian 4.1.2-14)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import twill
>>> twill.__version__
'0.9b1'
>>> 

Change History

08/29/07 15:31:14 changed by http://kevin.janrain.com/

further discussion. reduced to one failure after installing twill from a different package?

no failures on either my workstation at home or the office. difference between working systems and non-working has yet to be determined.

08/29/07 16:51:00 changed by http://j3h.us/

  • keywords changed from twill test failure to twill test failure debian lenny.

This ticket boils down to unit test failures using the Debian Lenny (testing) packaged version of twill. I have had similar problems with httplib2. We should figure out whether it's a packaging problem, a version-skew problem or something else.

08/29/07 16:52:35 changed by http://j3h.us/

Oh, the quoted error was due to a localhost/localhost.localdomain problem. That's been fixed. After the fix, the problems still occurred.

09/11/07 17:59:36 changed by http://keturn.myopenid.com/

  • summary changed from Twill unit tests for the Python example server don't work to Twill unit tests for the Python example server don't work using Lenny's Twill.

12/01/07 12:04:10 changed by http://keturn.myopenid.com/

this is reportedly true for Ubuntu Gutsy as well.

12/01/07 13:32:11 changed by http://radix.twistedmatrix.com/

I did some comparison of the tarball of twill versus the code installed by the pytho-twill package. It looks the same; there's a minor difference in where it writes the .twill_history file.

Notable is that Twill's source tarball contains a copy of mechanize, where the .deb package is just depending on the mechanize package. Both of those are 0.1.6b on my system, but there seem to be more significant changes in the mechanize package. Notice that it's changing some stuff about forms. I don't know if these differences came about from the debian packager diverging from the upstream mechanize source, or the twill authors having modified their copy of mechanize.

radix@haruko ~/.local/lib/python2.5/site-packages/twill/other_packages/mechanize% for x in *.py; do diff -u $x /usr/lib/python2.5/site-packages/mechanize/`basename $x`; done
--- _html.py    2007-03-06 18:00:05.000000000 -0500
+++ /usr/lib/python2.5/site-packages/mechanize/_html.py 2007-01-07 14:20:12.000000000 -0500
@@ -379,8 +379,7 @@
                 if not url:
                     continue
                 url = _rfc3986.clean_url(url, encoding)
-                text = link.fetchText(lambda t: True)
-                text = " ".join(text)
+                text = link.firstText(lambda t: True)
                 if text is _beautifulsoup.Null:
                     # follow _pullparser's weird behaviour rigidly
                     if link.name == "a":
--- _mechanize.py       2007-03-06 18:00:05.000000000 -0500
+++ /usr/lib/python2.5/site-packages/mechanize/_mechanize.py    2007-01-07 14:20:12.000000000 -0500
@@ -441,14 +441,6 @@
             raise ValueError(
                 "at least one argument must be supplied to specify form")
 
-        global_form = self.global_form()
-        if global_form.controls:
-            if name is not None and name == global_form.name:
-                self.form = global_form
-            if predicate is not None and predicate(global_form):
-                self.form = global_form
-            return
-
         orig_nr = nr
         for form in self.forms():
             if name is not None and name != form.name:
--- _request.py 2007-03-06 18:00:05.000000000 -0500
+++ /usr/lib/python2.5/site-packages/mechanize/_request.py      2007-01-07 14:20:12.000000000 -0500
@@ -49,7 +49,9 @@
         self.origin_req_host = origin_req_host
 
     def get_selector(self):
-        return urllib.splittag(self.__r_host)[0]
+        if self.selector is None:
+            self.selector, self.__r_selector = urllib.splittag(self.__r_host)
+        return self.selector
 
     def get_origin_req_host(self):
         return self.origin_req_host
--- _response.py        2007-03-06 18:00:05.000000000 -0500
+++ /usr/lib/python2.5/site-packages/mechanize/_response.py     2007-01-07 14:20:12.000000000 -0500
@@ -413,8 +413,7 @@
 
     Accepts responses from both mechanize and urllib2 handlers.
     """
-    if (isinstance(response, urllib2.HTTPError) and
-        not isinstance(response, response_seek_wrapper)):
+    if isinstance(response, urllib2.HTTPError):
         class httperror_seek_wrapper(response_seek_wrapper, response.__class__):
             # this only derives from HTTPError in order to be a subclass --
             # the HTTPError behaviour comes from delegation

05/30/08 13:43:03 changed by http://dag.myopenid.com/

  • priority changed from major to minor.