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 #1404 (closed defect: fixed)

Opened 10 years ago

Last modified 9 years ago

[PATCH] test_nested_widgets fails in isolation

Reported by: PeterRussell Owned by: anonymous
Priority: normal Milestone: 1.5
Component: Tests Version: 1.0.2
Severity: normal Keywords:
Cc:

Description

Background:

In trying to debug a CompoundFormField?, I was trying to work out what I needed to do to get my widget values nested properly. I came across the following thread:  http://thread.gmane.org/gmane.comp.web.turbogears/27475/ Alberto Valverde's response to which was that the posted test case shouldn't fail, given that it's almost exactly the same as turbogears.widgets.tests.test_nested_widgets, which passes. Thing is, it doesn't.


Steps to reproduce: In a turbogears installation run nosetests:

$ nosetests 
.........................No handlers could be found for logger "turbogears.identity"
......................................................................................................................................................................................................................................
----------------------------------------------------------------------
Ran 255 tests in 12.374s

Apparently fine, but:

$ nosetests turbogears.widgets.tests.test_nested_widgets
..F..............
======================================================================
FAIL: (turbogears.widgets.tests.test_nested_widgets.TestNestedWidgets) "
        Checks if names fo the widgets are set correctly depending on their
        path.
        "
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/psr/lib/python2.5/nose-0.9.3-py2.5.egg/nose/case.py", line 132, in runTest
    self.testCase(*self.arg)
  File "/home/psr/lib/python2.5/TurboGears-1.0.2.2-py2.5.egg/turbogears/widgets/tests/test_nested_widgets.py", line 57, in test_display
    re.compile('.*'.join([name_p, value_p])).search(output))
AssertionError

----------------------------------------------------------------------
Ran 17 tests in 1.467s

FAILED (failures=1)

So something in one of the other tests is making that particular module pass when it should fail.

Presumably nested widgets do work, but not in the way that the unit tests indicate they do.

Attachments

test_nested_widgets.diff Download (865 bytes) - added by PeterRussell 10 years ago.
Patch to fix test_nested_widgets.py

Change History

Changed 10 years ago by PeterRussell

Patch to fix test_nested_widgets.py

comment:1 Changed 10 years ago by PeterRussell

  • Summary changed from test_nested_widgets fails in isolation to [PATCH] test_nested_widgets fails in isolation

OK, so I've finally managed to figure out what's going on here (patch attached)

The test module was setting cherrpy.request to a dummy request object. However the modules turbogears.util and turbogears.widgets.forms had both already done "from cherrypy import request", meaning all operations they perform are on the threadlocalproxy instance, not the dummy object.

The attached patch puts the dummy request in cherrypy.serving.request (which is where the threadlocalproxy thingy points).

The reason that the test passed when run with other tests (turbogears.widgets.tests.test_multiple_form_controllers for one) were creating requests, thereby putting something in cherrypy.serving.request, and shadowing the fact that the dummy object wasn't being used. Solving that problem would be harder.

comment:2 Changed 10 years ago by Chris Arndt

  • Milestone changed from 1.0.3 to 1.0.4

Batch promoting 1.0.3 tickets to Milestone 1.0.4

comment:3 Changed 10 years ago by faide

  • Milestone changed from 1.0.4 to 1.1

Even when I apply the patch the test continues to pass correctly. I don't see any difference.

And when I try to run this test in isolation, either with or without this patch I get another error not related to this test.

comment:4 Changed 9 years ago by faide

  • Milestone changed from 1.1 to 1.1.1

any news on this ?

comment:5 Changed 9 years ago by kskuhlman

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

I fixed this in the 1.1 branch in [4596] by creating an actual request, not a dummy. Sorry, didn't see this ticket before.

comment:6 Changed 9 years ago by PeterRussell

Great, thanks for that

comment:7 Changed 9 years ago by kskuhlman

  • Milestone changed from 1.6 to 1.5
Note: See TracTickets for help on using tickets.