Changeset 12598
- Timestamp:
- 11 Feb 2015, 16:22:44 (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/waeup.kofa/trunk/src/waeup/kofa/testing.py
r12595 r12598 44 44 allow_teardown=True) 45 45 46 46 47 def get_all_loggers(): 47 48 """Get the keys of all logger defined globally. … … 53 54 print "\nLOGGERS: ", ws_loggers 54 55 return result 56 55 57 56 58 def remove_new_loggers(old_loggers): … … 71 73 return 72 74 75 73 76 def remove_logger(name): 74 77 """Remove logger with name `name`. … … 88 91 zope.component.eventtesting.setUp(test) 89 92 93 90 94 def cleanUpZope(test=None): 91 95 """Clean up Zope-related registrations. … … 94 98 """ 95 99 cleanUp() 100 96 101 97 102 def maybe_grok(): … … 178 183 179 184 """ 180 gsm = 185 gsm = getGlobalSiteManager() 181 186 # If there are any event handlers registered already, we assume 182 187 # that waeup.kofa was grokked already. There might be a batter … … 186 191 # Register the zope.Public permission, normally done via ZCML setup. 187 192 addCheckerPublic() 188 warnings.simplefilter('ignore') # disable (erraneous) warnings193 warnings.simplefilter('ignore') # disable (erraneous) warnings 189 194 grok.testing.grok('waeup.kofa') 190 warnings.simplefilter('default') # reenable warnings195 warnings.simplefilter('default') # reenable warnings 191 196 return True 197 192 198 193 199 def setup_datacenter_conf(): … … 204 210 return 205 211 212 206 213 def teardown_datacenter_conf(): 207 214 """Unregister a datacenter config utility for non-functional tests. … … 216 223 gsm.unregisterUtility(conf, IDataCenterConfig) 217 224 return 225 218 226 219 227 class KofaUnitTestLayer(object): … … 300 308 # http://reinout.vanrees.org/weblog/2009/07/16/invisible-test-diff.html: 301 309 (re.compile(r'.*1034h'), ''), 302 (re.compile(r'httperror_seek_wrapper:'), 'HTTPError:' 310 (re.compile(r'httperror_seek_wrapper:'), 'HTTPError:'), 303 311 (re.compile('[\d]{6}'), '<6-DIGITS>'), 304 312 (re.compile('[\d]{10}'), '<10-DIGITS>'), … … 309 317 ]) 310 318 319 311 320 old_loggers = [] 321 322 312 323 def setUp(test): 324 global old_loggers 313 325 old_loggers = get_all_loggers() 314 326 FunctionalTestSetup().setUp() 315 327 328 316 329 def tearDown(test): 330 global old_loggers 317 331 FunctionalTestSetup().tearDown() 318 332 remove_new_loggers(old_loggers) 319 333 334 320 335 def doctestsuite_for_module(dotted_path): 321 336 """Create a doctest suite for the module at `dotted_path`. … … 323 338 test = doctest.DocTestSuite( 324 339 dotted_path, 325 setUp =setUp,326 tearDown =tearDown,327 checker =checker,328 extraglobs =dict(340 setUp=setUp, 341 tearDown=tearDown, 342 checker=checker, 343 extraglobs=dict( 329 344 getRootFolder=getRootFolder, 330 345 sync=sync,), 331 optionflags =(doctest.ELLIPSIS +332 333 346 optionflags=(doctest.ELLIPSIS + 347 doctest.NORMALIZE_WHITESPACE + 348 doctest.REPORT_NDIFF), 334 349 ) 335 350 test.layer = FunctionalLayer 336 351 return test 337 352 353 338 354 optionflags = ( 339 355 doctest.REPORT_NDIFF + doctest.ELLIPSIS + doctest.NORMALIZE_WHITESPACE) 340 356 357 341 358 def clear_logger_collector(): 342 from zope.component import queryUtility , getGlobalSiteManager359 from zope.component import queryUtility 343 360 from waeup.kofa.interfaces import ILoggerCollector 344 361 collector = queryUtility(ILoggerCollector) … … 349 366 del collector[key] 350 367 return 368 351 369 352 370 class FunctionalTestCase(FunctionalTestCase): … … 388 406 self.fail(diff) 389 407 408 390 409 class FunctionalTestSetup(FunctionalTestSetup): 391 410 """A replacement for the zope.app.testing class. … … 403 422 remove_new_loggers(self.old_loggers) 404 423 return 424 405 425 406 426 def get_doctest_suite(filename_list=[]): … … 431 451 module_relative=False, 432 452 setUp=setUp, tearDown=tearDown, 433 globs = dict(getRootFolder =getRootFolder),434 optionflags =doctest.ELLIPSIS + doctest.NORMALIZE_WHITESPACE,435 checker =checker,453 globs=dict(getRootFolder=getRootFolder), 454 optionflags=doctest.ELLIPSIS + doctest.NORMALIZE_WHITESPACE, 455 checker=checker, 436 456 ) 437 457 test.layer = FunctionalLayer 438 458 suite.addTest(test) 439 459 return suite 460 440 461 441 462 class FakeJob(object): … … 448 469 self.args = args 449 470 self.kwargs = kw 471 450 472 451 473 class FakeJobManager(object):
Note: See TracChangeset for help on using the changeset viewer.