Changeset 12595 for main/waeup.kofa/trunk/src/waeup
- Timestamp:
- 11 Feb 2015, 15:28:49 (10 years ago)
- Location:
- main/waeup.kofa/trunk/src/waeup/kofa
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/browser/tests/test_async.py
r12581 r12595 3 3 import tempfile 4 4 import transaction 5 from contextlib import contextmanager6 5 from zc.async.testing import wait_for_result 7 6 from zope.component import getUtility … … 12 11 from waeup.kofa.async import AsyncJob, get_job_id 13 12 from waeup.kofa.interfaces import IJobManager, IKofaUtils 14 from waeup.kofa.testing import FunctionalTestCase, FunctionalLayer 13 from waeup.kofa.testing import ( 14 FunctionalTestCase, FunctionalLayer, expensive_actions, 15 ) 15 16 from waeup.kofa.tests.test_async import FunctionalAsyncTestCase 16 17 … … 22 23 def dummy_func(): 23 24 return 42 24 25 26 @contextmanager27 def expensive_actions():28 """A contextmanager to work with a modified `expensive_acrtions_allowed()`29 30 This method is part of local IKofaUtils.31 """32 utils = getUtility(IKofaUtils)33 old_func = utils.expensive_actions_allowed34 try:35 yield utils36 finally:37 # restore function after use38 utils.expensive_actions_allowed = old_func39 25 40 26 -
main/waeup.kofa/trunk/src/waeup/kofa/testing.py
r12582 r12595 29 29 import zope.component 30 30 import waeup.kofa 31 from contextlib import contextmanager 31 32 from zc.async.interfaces import COMPLETED 32 33 from zope.app.testing.functional import ( 33 34 ZCMLLayer, FunctionalTestSetup, getRootFolder, sync, FunctionalTestCase) 34 from zope.component import getGlobalSiteManager, queryUtility 35 from zope.component import getGlobalSiteManager, queryUtility, getUtility 35 36 from zope.security.testing import addCheckerPublic 36 37 from zope.testing import renormalizing 37 38 from zope.testing.cleanup import cleanUp 39 from waeup.kofa.interfaces import IKofaUtils 38 40 39 41 ftesting_zcml = os.path.join( … … 472 474 del self._jobs[job_id] 473 475 return 476 477 478 @contextmanager 479 def expensive_actions(): 480 """A contextmanager to work with a modified `expensive_acrtions_allowed()` 481 482 This method is part of local IKofaUtils. 483 """ 484 utils = getUtility(IKofaUtils) 485 old_func = utils.expensive_actions_allowed 486 try: 487 yield utils 488 finally: 489 # restore function after use 490 utils.expensive_actions_allowed = old_func
Note: See TracChangeset for help on using the changeset viewer.