[Zope3-checkins] Re: [Checkins] SVN: Zope3/trunk/src/zope/app/testing/functional.py Implement ZCMLLayer.tearDown.

Jim Fulton jim at zope.com
Wed Jan 24 10:42:14 EST 2007


Gary pointed out to me that there was a real benefit for him in  
having zope.app.testing.setup.placefulTearDown run.  I suggest an  
alternate change, which is to have the layer tearDown method call  
zope.app.testing.setup.placefulTearDown and then raise  
NotImplementedError.

Jim

On Jan 24, 2007, at 10:27 AM, Jim Fulton wrote:

>
> On Jan 20, 2007, at 9:16 AM, Marius Gedminas wrote:
>
>> Log message for revision 72143:
>>   Implement ZCMLLayer.tearDown.
>>
>>   As a result, the test runner no longer needs to run functional  
>> tests of all but
>>   the first layer in a subprocess, and you get progress indication  
>> and also can
>>   use pdb there.
>>
>>   All tests (test.py --all) pass with this change.  I've also  
>> checked the
>>   contents of the adapter registry, the logging module  
>> configuration, the
>>   contents of the transaction, and the list of loggers registered  
>> with the Python
>>   logging framework.  All these are not changed by setting up and  
>> tearing down
>>   test layers.
>
> This doesn't work.  Unfortunately, there are side effects of ZCML  
> that you aren't undoing.  In particular, for better or worse, ZCML  
> often makes changes to module globals that are not cleaned up by  
> the testing cleanup machinery.
>
> This change caused several test failures in a large application of  
> ours.
>
> Please revert this change.
>
> Jim
>
>>
>>
>>
>> Changed:
>>   U   Zope3/trunk/src/zope/app/testing/functional.py
>>
>> -=-
>> Modified: Zope3/trunk/src/zope/app/testing/functional.py
>> ===================================================================
>> --- Zope3/trunk/src/zope/app/testing/functional.py	2007-01-20  
>> 13:53:49 UTC (rev 72142)
>> +++ Zope3/trunk/src/zope/app/testing/functional.py	2007-01-20  
>> 14:16:24 UTC (rev 72143)
>> @@ -171,6 +171,12 @@
>>          self.db.close()
>>          setSite(None)
>>
>> +    def tearDownCompletely(self):
>> +        """Cleans up the setup done by the constructor."""
>> +        zope.app.testing.setup.placefulTearDown()
>> +        self._config_file = False
>> +        self._init = False
>> +
>>      def getRootFolder(self):
>>          """Returns the Zope root folder."""
>>          if not self.connection:
>> @@ -182,6 +188,7 @@
>>          """Returns the Zope application instance."""
>>          return self.app
>>
>> +
>>  class ZCMLLayer:
>>      """ZCML-defined test layer
>>      """
>> @@ -194,11 +201,12 @@
>>          self.__name__ = name
>>
>>      def setUp(self):
>> -        FunctionalTestSetup(self.config_file)
>> +        self.setup = FunctionalTestSetup(self.config_file)
>>
>>      def tearDown(self):
>> -        raise NotImplementedError
>> +        self.setup.tearDownCompletely()
>>
>> +
>>  def defineLayer(name, zcml='test.zcml'):
>>      """Helper function for defining layers.
>>
>>
>> _______________________________________________
>> Checkins mailing list
>> Checkins at zope.org
>> http://mail.zope.org/mailman/listinfo/checkins
>
> --
> Jim Fulton			mailto:jim at zope.com		Python Powered!
> CTO 				(540) 361-1714			http://www.python.org
> Zope Corporation	http://www.zope.com		http://www.zope.org
>
>
>
> _______________________________________________
> Checkins mailing list
> Checkins at zope.org
> http://mail.zope.org/mailman/listinfo/checkins

--
Jim Fulton			mailto:jim at zope.com		Python Powered!
CTO 				(540) 361-1714			http://www.python.org
Zope Corporation	http://www.zope.com		http://www.zope.org





More information about the Zope3-Checkins mailing list