On Sat, Mar 27, 2010 at 3:40 AM, grassoalvaro <[email protected]> wrote:
> Hi,
>
> i have problem with some automatic tests. Simple example:
>
> [code]
>
> from test.tests import *
> from pylons import tmpl_context as c
>
> class TestBlaController(TestController):
>
>    def test_index(self):
>        response = self.app.get(url(controller='bla', action='index'))
>        c.test = 'dupa'
>
>
> [/code]
>
>
> p...@ra:~/test$ nosetests -s test/tests/functional/test_bla.py
> Running setup_config() from test.websetup
> E
> ======================================================================
> ERROR: test_index (test.tests.functional.test_bla.TestBlaController)
> ----------------------------------------------------------------------
> Traceback (most recent call last):
>  File "/home/pako/test/test/tests/functional/test_bla.py", line 8, in
> test_index
>    c.test = 'dupa'
>  File "/usr/lib/python2.5/site-packages/Paste-1.7.2-py2.5.egg/paste/
> registry.py", line 140, in __setattr__
>    setattr(self._current_obj(), attr, value)
>  File "/usr/lib/python2.5/site-packages/Paste-1.7.2-py2.5.egg/paste/
> registry.py", line 194, in _current_obj
>    'thread' % self.____name__)
> TypeError: No object (name: tmpl_context or C) has been registered for
> this thread
>
> ----------------------------------------------------------------------
> Ran 1 test in 0.005s
>
> FAILED (errors=1)
>
>
> How to register tmpl_context? (I'm testing of course other module
> where i can't change code using templates, below it's only simple
> example).

There's either a new bug in the testing framework or we need guidance
from a Pylons testing expert. This is the same as the problems in the
"Pylons 1.0rc1 runtime configuration" thread.
pylons.tmpl_context/config/url are thread-safe proxies for the actual
objects The error "no object has been registered for this thread"
means that the actual objects haven't been properly pushed onto the
proxies.  That's Pylons' responsibility, not yours. Your
responsibility is to use the proxies only in the appropriate places.
But inside a test controller method -- or in anything it calls -- *is*
an appropriate place, so this error shouldn't be happening.

-- 
Mike Orr <[email protected]>

-- 
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en.

Reply via email to