Guys, thanks for the insights.
On Tue, Jan 25, 2011 at 2:11 PM, Daniel Holth <dho...@gmail.com> wrote: > Typically my models are not very smart, so I am not usually worried about > model-bugs interfering with other tests and I just insert real ones into a > sqlite:///:memory: database. However, > > def view_under_test(request): > return > dict(user_id=request.db.query(User).get(authenticated_userid(request)).user_id) > > class ClassyView(object): > User=User > ... > > # ... another file: > > def test_view(): > # I do define mock objects at function scope and do not re-use them: > class Request(object): pass > class User(object): user_id = 4 > class SQLAlchemy(object): > def query(self, klass): return self > def get(self): return User() > r = Request() > r.db = SQLAlchemy() > assert view_under_test(r)['user_id'] == 4 > > def test_classy_view(): > cv = ClassyView() > class User(object): pass > cv.User = User > ... > > -- > You received this message because you are subscribed to the Google Groups > "pylons-devel" group. > To post to this group, send email to pylons-devel@googlegroups.com. > To unsubscribe from this group, send email to > pylons-devel+unsubscr...@googlegroups.com<pylons-devel%2bunsubscr...@googlegroups.com> > . > For more options, visit this group at > http://groups.google.com/group/pylons-devel?hl=en. > -- You received this message because you are subscribed to the Google Groups "pylons-devel" group. To post to this group, send email to pylons-devel@googlegroups.com. To unsubscribe from this group, send email to pylons-devel+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/pylons-devel?hl=en.