Warning: Can't synchronize with repository "(default)" (Unsupported version control system "svn": No module named svn). Look in the Trac log for more information.

Ticket #1376 (closed defect: fixed)

Opened 12 years ago

Last modified 12 years ago

Failing test using python2.5

Reported by: alberto Owned by: faide
Priority: high Milestone: 1.0.2
Component: TurboGears Version: 1.0.1
Severity: blocker Keywords: 2.5 json ambiguousmethod
Cc: elvelind kevin

Description

There's a failing test when using python2.5, here's the output:

======================================================================
ERROR: turbogears.tests.test_expose.test_allow_json
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/alberto/src/python/environments/Turbogears25/lib/python2.5/nose-0.9.3-py2.5.egg/nose/case.py", line 52, in runTest
    self.testFunc()
  File "/Users/alberto/src/python/checkouts/turbogears/turbogears/tests/test_expose.py", line 74, in test_allow_json
    values = simplejson.loads(cherrypy.response.body[0])
  File "/Users/alberto/src/python/environments/Turbogears25/lib/python2.5/simplejson-1.7.1-py2.5.egg/simplejson/__init__.py", line 262, in loads
    return _default_decoder.decode(s)
  File "/Users/alberto/src/python/environments/Turbogears25/lib/python2.5/simplejson-1.7.1-py2.5.egg/simplejson/decoder.py", line 251, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/Users/alberto/src/python/environments/Turbogears25/lib/python2.5/simplejson-1.7.1-py2.5.egg/simplejson/decoder.py", line 270, in raw_decode
    raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded

-------------------- >> begin captured stdout << ---------------------
Got record: <LogRecord: turbogears.controllers, 10, /Users/alberto/src/python/checkouts/turbogears/turbogears/controllers.py, 219, "Adding allow_json rule: allow_json and (kw.get("tg_format", None) == "json" or accept =="text/javascript")">
formatted as: Adding allow_json rule: allow_json and (kw.get("tg_format", None) == "json" or accept =="text/javascript")
Got record: <LogRecord: turbogears.controllers, 10, /Users/alberto/src/python/checkouts/turbogears/turbogears/controllers.py, 211, "Generated rule %s">
formatted as: Generated rule kw.get("tg_format", "default") == "default"
Adding allow_json rule: allow_json and (kw.get("tg_format", None) == "json" or accept =="text/javascript")
Generated rule kw.get("tg_format", "default") == "default"
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"></meta>
    <title>500 Internal error</title>
    <style type="text/css">
    #powered_by {
        margin-top: 20px;
        border-top: 2px solid black;
        font-style: italic;
    }

    #traceback {
        color: red;
    }
    </style>
</head>
    <body>
        <h2>500 Internal error</h2>
        <p>The server encountered an unexpected condition which prevented it from fulfilling the request.</p>
        <pre id="traceback">Page handler: &lt;bound method NewRoot.test of &lt;turbogears.tests.test_expose.NewRoot object at 0x27a9c90&gt;&gt;
Traceback (most recent call last):
  File "/Users/alberto/src/python/environments/Turbogears25/lib/python2.5/CherryPy-2.2.1-py2.5.egg/cherrypy/_cphttptools.py", line 105, in _run
    self.main()
  File "/Users/alberto/src/python/environments/Turbogears25/lib/python2.5/CherryPy-2.2.1-py2.5.egg/cherrypy/_cphttptools.py", line 254, in main
    body = page_handler(*virtual_path, **self.params)
  File "&lt;string&gt;", line 3, in test
  File "/Users/alberto/src/python/checkouts/turbogears/turbogears/controllers.py", line 336, in expose
    *args, **kw)
  File "&lt;string&gt;", line 5, in run_with_transaction
  File "/Users/alberto/src/python/checkouts/turbogears/turbogears/database.py", line 303, in so_rwt
    retval = func(*args, **kw)
  File "&lt;string&gt;", line 5, in _expose
  File "_d_speedups.pyx", line 403, in _d_speedups.BaseDispatcher.__getitem__
  File "/Users/alberto/src/python/environments/Turbogears25/lib/python2.5/RuleDispatch-0.5a0.dev_r2306-py2.5-macosx-10.3-fat.egg/dispatch/interfaces.py", line 15, in __call__
    raise self.__class__(*self.args+(args,kw))
AmbiguousMethod: ([(Signature((2, &lt;class 'dispatch.strategy.Node'&gt;)=TruthCriterion(True),(1, &lt;class 'dispatch.strategy.node_type'&gt;)=Inequality("..",(('text/javascript', 'text/javascript'),))), &lt;function &lt;lambda&gt; at 0x27fb5f0&gt;), (Signature((9, &lt;class 'dispatch.strategy.node_type'&gt;)=Inequality("..",(('default', 'default'),))), &lt;function &lt;lambda&gt; at 0x27fb2f0&gt;)], (&lt;function test at 0x27fb230&gt;, 'text/javascript', True, (&lt;turbogears.tests.test_expose.NewRoot object at 0x27a9c90&gt;,), {}), {})
</pre>
    <div id="powered_by">
    <span>Powered by <a href="http://www.cherrypy.org">CherryPy 2.2.1</a></span>
    </div>
    </body>
</html>


--------------------- >> end captured stdout << ----------------------
----------------------------------------------------------------------

Any clues what might be causing it?

Alberto

Attachments

tg102py25.patch Download (10.3 KB) - added by chrisz 12 years ago.
Fix for failing tests under Python 2.5

Change History

comment:1 Changed 12 years ago by chrisz

I have examined this problem a little deeper and found it is caused by the fact that exceptions in Python 2.5 are new-style classes, so a comparison with InstanceType? in controller.py falls through. I have attached a patch to the current 1.0 branch after which all tests run thorugh in Python 2.4 and 2.5.

Changed 12 years ago by chrisz

Fix for failing tests under Python 2.5

comment:2 Changed 12 years ago by faide

  • Owner changed from anonymous to faide
  • Status changed from new to assigned

comment:3 Changed 12 years ago by faide

  • Status changed from assigned to closed
  • Resolution set to fixed

Applied... Many layers of thanks ;-]

Note: See TracTickets for help on using tickets.