On Tuesday 01 December 2009 04:58:20 steve wrote:
> the controllers and template is pretty straight forward.  when i visit
> it on a browser via paster serve, it displays properly when given a
> valid id in the db.  as for the exception during nosetests, it is the
> same one u would get when you provide an invalid id at GET /contacts/
> [invalid_id].  this confuses me b/c the print statement in my test
> case validates that the row is in the test database.  however, when
> you hit self.app.get(' /contacts/[contact_id]'), the exception it
> throws indicate that the id is invalid, hence contact is None, and
> hence 'None has no member named "full_name"'.

You don't show how you actually create the user. What gives us troubles in 
these cases is that you have to create data inside a test within it's own 
transaction. Otherwise, it's of course not visible to the *next* transaction 
which is openend via self.app.get

Because of various issues with the transaction-handling in TG2, we ripped this 
out (the whole zope.transaction-stuff), and rolled our own middleware which 
simply applies a 

  @transactional

decorator around a call. This same decorator we use in tests:


class MyTest(...):


   def test_something(self):
         @transactional
         def create_testuser():
               return User(name='test').id

         user_id = create_testuser()
         self.app.get("/test/%i" % user_id)





HTH,

Diez

--

You received this message because you are subscribed to the Google Groups 
"TurboGears" 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/turbogears?hl=en.


Reply via email to