-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 01/25/2011 01:38 PM, Ryan wrote:
> I use PyMox for mocking in unit testing of models. While testing views, I'd 
> like to mock model methods as well. Any examples of how to do this?
> 
> Or, is this the wrong approach? Should the view tests be considered full 
> integration tests, and therefore not be mocked?

+1 for unit-testing view code:  real integration tests are too fragile
in the face of what should be "trivial" changes to templating.

I find that using the "external renderer" pattern  (adding the renderer
via ZCML or imperative configuration code) makes this much easier, as I
can just test the values (usually a dict) returned by the view function.

I tend to mock up context^Wmodel^Wresource using either a simple mock
class (I dont bother importing it from anywhere):

  class Dummy(object):
      def __init__(self, **kw):
          self.__dict__.update(kw)

or else the 'DummyModel' class from repoze.bfg^W^W^Wpyramid.testing:



Tres.
- -- 
===================================================================
Tres Seaver          +1 540-429-0999          tsea...@palladion.com
Palladion Software   "Excellence by Design"    http://palladion.com
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk0/Ib0ACgkQ+gerLs4ltQ7BagCfflng3sYVq2/XrEvaSpvPn8tx
03oAn3kDgWQAEKkQu5XUiAbClISuTAYf
=EbGD
-----END PGP SIGNATURE-----

-- 
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.

Reply via email to