-
Indispensable pytest plugins
Read more »: Indispensable pytest pluginsI’ve been babbling on about testing for a decade now. Here’s a quick list of pytest plugins I use in most of my Python projects: pytest-cov – pytest integration for the wonderful coverage tool by Ned Batchelder. pytest-mock – pytest integration for the unittest.mock library. pytest-instafail – Print out the test failure as it…
-
Load overrides.zcml in plone.app.testing
Read more »: Load overrides.zcml in plone.app.testingToday I was working on a project where we use overrides.zcml to easily override some default Plone behavior. All was working fine (in the browser, that is) until I started writing tests for our custom behavior. First thing I noticed was that the overrides.zcml was not loaded in our test layer. “Doh, I need to…
-
Robot on Travis – uploading results to S3
Read more »: Robot on Travis – uploading results to S3This is a walkthrough of how one could upload to Amazon S3 screenshots and other output files produced by Robot framework ran in a Travis CI build. The reason why we want to do this is to be able to inspect what Robot sees and have more information when a test fails. It’s written with some…
-
Testing log output
Read more »: Testing log outputATTRIBUTION: This post was inspired by Domen’s Mocking logging module for unittests post back from 2009. Most of the code below is from him, with some added Plone specific bits and pieces. I was recently debugging an installation of our niteoweb.click2sell and had the need for more verbose error handling. After adding support for it…
-
Testing memoized methods
Read more »: Testing memoized methodsFor a recent Plone project we needed to write unit tests for methods that were using plone.memoize for caching return values. With a standard Plone’s PloneTestCase I got the following error: Error in test test_main_image (niteoweb.elcond.tests.test_stol.TestContent) Traceback (most recent call last): File “/Users/zupo/work/python/parts/opt/lib/python2.6/unittest.py”, line 279, in run testMethod() File “/Users/zupo/work/niteoweb.elcond/src/niteoweb/elcond/tests/test_stol.py”, line 75, in test_main_image image…
-
Testing session in Plone 3.3
Read more »: Testing session in Plone 3.3Yesterday, while I was working on LifeInLjubljana.si, I had to test if some data was correctly written to Plone’s session. I couldn’t use the standard ptc.FunctionalTestCase test case as it does not have a session and I would get errors like this: (Pdb) self.context.session_data_manager *** AttributeError: session_data_manager (Pdb) self.context.REQUEST.SESSION *** AttributeError: SESSION Following a tip…