Changeset 12598 for main


Ignore:
Timestamp:
11 Feb 2015, 16:22:44 (10 years ago)
Author:
uli
Message:

flake8.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/waeup.kofa/trunk/src/waeup/kofa/testing.py

    r12595 r12598  
    4444                            allow_teardown=True)
    4545
     46
    4647def get_all_loggers():
    4748    """Get the keys of all logger defined globally.
     
    5354        print "\nLOGGERS: ", ws_loggers
    5455    return result
     56
    5557
    5658def remove_new_loggers(old_loggers):
     
    7173    return
    7274
     75
    7376def remove_logger(name):
    7477    """Remove logger with name `name`.
     
    8891    zope.component.eventtesting.setUp(test)
    8992
     93
    9094def cleanUpZope(test=None):
    9195    """Clean up Zope-related registrations.
     
    9498    """
    9599    cleanUp()
     100
    96101
    97102def maybe_grok():
     
    178183
    179184    """
    180     gsm =  getGlobalSiteManager()
     185    gsm = getGlobalSiteManager()
    181186    # If there are any event handlers registered already, we assume
    182187    # that waeup.kofa was grokked already. There might be a batter
     
    186191    # Register the zope.Public permission, normally done via ZCML setup.
    187192    addCheckerPublic()
    188     warnings.simplefilter('ignore') # disable (erraneous) warnings
     193    warnings.simplefilter('ignore')   # disable (erraneous) warnings
    189194    grok.testing.grok('waeup.kofa')
    190     warnings.simplefilter('default') # reenable warnings
     195    warnings.simplefilter('default')  # reenable warnings
    191196    return True
     197
    192198
    193199def setup_datacenter_conf():
     
    204210    return
    205211
     212
    206213def teardown_datacenter_conf():
    207214    """Unregister a datacenter config utility for non-functional tests.
     
    216223    gsm.unregisterUtility(conf, IDataCenterConfig)
    217224    return
     225
    218226
    219227class KofaUnitTestLayer(object):
     
    300308    # http://reinout.vanrees.org/weblog/2009/07/16/invisible-test-diff.html:
    301309    (re.compile(r'.*1034h'), ''),
    302     (re.compile(r'httperror_seek_wrapper:'), 'HTTPError:' ),
     310    (re.compile(r'httperror_seek_wrapper:'), 'HTTPError:'),
    303311    (re.compile('[\d]{6}'), '<6-DIGITS>'),
    304312    (re.compile('[\d]{10}'), '<10-DIGITS>'),
     
    309317    ])
    310318
     319
    311320old_loggers = []
     321
     322
    312323def setUp(test):
     324    global old_loggers
    313325    old_loggers = get_all_loggers()
    314326    FunctionalTestSetup().setUp()
    315327
     328
    316329def tearDown(test):
     330    global old_loggers
    317331    FunctionalTestSetup().tearDown()
    318332    remove_new_loggers(old_loggers)
    319333
     334
    320335def doctestsuite_for_module(dotted_path):
    321336    """Create a doctest suite for the module at `dotted_path`.
     
    323338    test = doctest.DocTestSuite(
    324339        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(
    329344            getRootFolder=getRootFolder,
    330345            sync=sync,),
    331         optionflags = (doctest.ELLIPSIS +
    332                        doctest.NORMALIZE_WHITESPACE +
    333                        doctest.REPORT_NDIFF),
     346        optionflags=(doctest.ELLIPSIS +
     347                     doctest.NORMALIZE_WHITESPACE +
     348                     doctest.REPORT_NDIFF),
    334349        )
    335350    test.layer = FunctionalLayer
    336351    return test
    337352
     353
    338354optionflags = (
    339355    doctest.REPORT_NDIFF + doctest.ELLIPSIS + doctest.NORMALIZE_WHITESPACE)
    340356
     357
    341358def clear_logger_collector():
    342     from zope.component import queryUtility, getGlobalSiteManager
     359    from zope.component import queryUtility
    343360    from waeup.kofa.interfaces import ILoggerCollector
    344361    collector = queryUtility(ILoggerCollector)
     
    349366        del collector[key]
    350367    return
     368
    351369
    352370class FunctionalTestCase(FunctionalTestCase):
     
    388406        self.fail(diff)
    389407
     408
    390409class FunctionalTestSetup(FunctionalTestSetup):
    391410    """A replacement for the zope.app.testing class.
     
    403422        remove_new_loggers(self.old_loggers)
    404423        return
     424
    405425
    406426def get_doctest_suite(filename_list=[]):
     
    431451            module_relative=False,
    432452            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,
    436456            )
    437457        test.layer = FunctionalLayer
    438458        suite.addTest(test)
    439459    return suite
     460
    440461
    441462class FakeJob(object):
     
    448469        self.args = args
    449470        self.kwargs = kw
     471
    450472
    451473class FakeJobManager(object):
Note: See TracChangeset for help on using the changeset viewer.