Ñò ý÷òGc @s^dZddkZddkZddkZddklZddklZddkl Z dddd d gZ ei e ƒZ d efd „ƒYZd efd„ƒYZdefd„ƒYZddd„ƒYZdefd„ƒYZd efd„ƒYZy)ddkZdeefd„ƒYZWnej o eZnXd efd„ƒYZdS(sZ Plugin Manager -------------- A plugin manager class is used to load plugins, manage the list of loaded plugins, and proxy calls to those plugins. The plugin managers provided with nose are: ``PluginManager`` This manager doesn't implement loadPlugins, so it can only work with a static list of plugins. ``BuiltinPluginManager`` This manager loads plugins referenced in ``nose.plugins.builtin``. ``EntryPointPluginManager`` This manager uses setuptools entrypoints to load plugins. ``DefaultPluginMananger`` This is the manager class that will be used by default. If setuptools is installed, it is a subclass of ``EntryPointPluginManager`` and ``BuiltinPluginManager``; otherwise, an alias to ``BuiltinPluginManager``. ``RestrictedPluginManager`` This manager is for use in test runs where some plugin calls are not available, such as runs started with `python setup.py test`, where the test runner is the default unittest ``TextTestRunner``. It is a subclass of ``DefaultPluginManager``. Writing a plugin manager ======================== If you want to load plugins via some other means, you can write a plugin manager and pass an instance of your plugin manager class when instantiating the `nose.config.Config`_ instance that you pass to ``TestProgram`` (or ``main`` or ``run``). To implement your plugin loading scheme, implement ``loadPlugins()``, and in that method, call ``addPlugin()`` with an instance each plugin you wish to make available. Make sure to call ``super(self).loadPlugins()`` as well if have subclassed a manager other than ``PluginManager``. iÿÿÿÿN(twarn(tFailure(tIPluginInterfacetDefaultPluginManagert PluginManagertEntryPointPluginManagertBuiltinPluginManagertRestrictedPluginManagert PluginProxycBs_eZdZeZd„Zd„Zd„Zd„Zd„Z d„Z d„Z d d„Z RS( s#Proxy for plugin calls. Essentially a closure bound to the given call and plugin list. The plugin proxy also must be bound to a particular plugin interface specification, so that it knows what calls are available and any special handling that is required for each call. cCs‹yt|i|ƒ|_Wn/tj o#td||iifƒ‚nX|i|ƒ|_g|_x|D]}|i||ƒqmWdS(Ns%s is not a valid %s method( tgetattrt interfacetmethodtAttributeErrort__name__tmakeCalltcalltpluginst addPlugin(tselfRRtp((s8/usr/lib/python2.6/site-packages/nose/plugins/manager.pyt__init__Es cOs|i||ŽS(N(R(Rtargtkw((s8/usr/lib/python2.6/site-packages/nose/plugins/manager.pyt__call__PscCs=t||dƒ}|dj o|ii||fƒndS(s`Add plugin to my list of plugins to call, if it has the attribute I'm bound to. N(R tNoneRtappend(RtpluginRtmeth((s8/usr/lib/python2.6/site-packages/nose/plugins/manager.pyRSs cse|djoˆiSˆi}t|dtƒo‡fd†St|dtƒoˆiSˆiSdS(NtloadTestsFromNamest generativecstˆi||ŽƒS((tlisttgenerate(RR(R(s8/usr/lib/python2.6/site-packages/nose/plugins/manager.pytest chainable(t_loadTestsFromNamesR R tFalsetchaintsimple(RRR((Rs8/usr/lib/python2.6/site-packages/nose/plugins/manager.pyR[s  c Os‘d}g}tt|idgƒ|ƒD]\}}|o ||q)q)~}x:|iD]/\}}|||Ž}|}|i|ƒqZW|S(s˜Call plugins in a chain, where the result of each plugin call is sent to the next plugin as input. The final output result is returned. t static_argsN(RtzipR R RR( RRRtresultt_[1]tstatictaRR((s8/usr/lib/python2.6/site-packages/nose/plugins/manager.pyR$ls( cosx–|iD]‹\}}d}y:|||Ž}|dj ox|D] }|VqBWnWq ttfj o ‚q tiƒ}t|ŒVq q Xq WdS(sFCall all plugins, yielding each item in each non-None result. N(RRtKeyboardInterruptt SystemExittsystexc_infoR(RRRRRR(trtexc((s8/usr/lib/python2.6/site-packages/nose/plugins/manager.pyR|s    cOs?x8|iD]-\}}|||Ž}|dj o|Sq WdS(s?Call all plugins, returning the first non-None result. N(RR(RRRRRR(((s8/usr/lib/python2.6/site-packages/nose/plugins/manager.pyR%s   cCsqg}x^|iD]S\}}||d|ƒ}|dj o(|\}}|o|i|ƒqcqqW||fS(s Chainable but not quite normal. Plugins return a tuple of (tests, names) after processing the names. The tests are added to a suite that is accumulated throughout the full call, while names are input for the next plugin in the chain. tmoduleN(RRtextend(RtnamesR2tsuiteRRR(t suite_part((s8/usr/lib/python2.6/site-packages/nose/plugins/manager.pyR"•s   N(R t __module__t__doc__RR RRRRR$RR%RR"(((s8/usr/lib/python2.6/site-packages/nose/plugins/manager.pyR<s      t NoPluginscBsqeZdZeZd„Zd„Zd„Zd„Zd„Z d„Z d„Z d„Z d „Z d d „ZRS( s(Null Plugin manager that has no plugins.cCs d|_dS(N((R(R((s8/usr/lib/python2.6/site-packages/nose/plugins/manager.pyR¨scCsdS(N(((R((s8/usr/lib/python2.6/site-packages/nose/plugins/manager.pyt__iter__«scOsdS(N((Rtargstkwds((s8/usr/lib/python2.6/site-packages/nose/plugins/manager.pyt _doNothing®scOsdS(N(((RR;R<((s8/usr/lib/python2.6/site-packages/nose/plugins/manager.pyt_emptyIterator±scCs8t|i|ƒ}t|dtƒo|iS|iSdS(NR(R R R#R>R=(RRR ((s8/usr/lib/python2.6/site-packages/nose/plugins/manager.pyt __getattr__´scCs tƒ‚dS(N(tNotImplementedError(Rtplug((s8/usr/lib/python2.6/site-packages/nose/plugins/manager.pyR»scCs tƒ‚dS(N(R@(RR((s8/usr/lib/python2.6/site-packages/nose/plugins/manager.pyt addPlugins¾scCsdS(N((Rtoptionstconfig((s8/usr/lib/python2.6/site-packages/nose/plugins/manager.pyt configureÁscCsdS(N((R((s8/usr/lib/python2.6/site-packages/nose/plugins/manager.pyt loadPluginsÄscCsdS(N((Rtcmpf((s8/usr/lib/python2.6/site-packages/nose/plugins/manager.pytsortÇsN(R R7R8RR RR:R=R>R?RRBRERFRRH(((s8/usr/lib/python2.6/site-packages/nose/plugins/manager.pyR9¥s         cBsŒeZdZeZd d d„Zd„Zd„Zd„Z d„Z d„Z d„Z d d„Z d „Zd „Zeeed d ƒZRS(s_Base class for plugin managers. Does not implement loadPlugins, so it may only be used with a static list of plugins. The basic functionality of a plugin manager is to proxy all unknown attributes through a ``PluginProxy`` to a list of plugins. Note that the list of plugins *may not* be changed after the first plugin call. cCsHg|_h|_|o|i|ƒn|dj o ||_ndS(N(t_pluginst_proxiesRBRt proxyClass(RRRK((s8/usr/lib/python2.6/site-packages/nose/plugins/manager.pyR×s    cCsKy|i|SWn5tj o)|i||iƒ}||i|Proxy for 0.9 plugins, adapts 0.10 calls to 0.9 standard. cCs ||_dS(N(R(RR((s8/usr/lib/python2.6/site-packages/nose/plugins/manager.pyRscCs|ii||ƒdS(N(Rt add_options(Rtparsertenv((s8/usr/lib/python2.6/site-packages/nose/plugins/manager.pyRCsc Cs×t|idƒpdSddkl}l}|\}}}t||ƒo,t|idƒpdS|ii|iƒSt||ƒo,t|idƒpdS|ii|iƒS|i }|ii |i||ƒS(NtaddErroriÿÿÿÿ(tSkipTesttDeprecatedTesttaddSkipt addDeprecated( thasattrRtnose.excR^R_t issubclassR`ttestRatcapturedOutputR]( RReterrR^R_tectevttbtcapt((s8/usr/lib/python2.6/site-packages/nose/plugins/manager.pyR]s cCs(t|idƒo|ii|ƒSdS(NtloadTestsFromPath(RbRRl(Rtfilename((s8/usr/lib/python2.6/site-packages/nose/plugins/manager.pytloadTestsFromFile/scCsFt|idƒpdS|i}|i}|ii|i|||ƒS(Nt addFailure(RbRRfttbinfoRoRe(RReRgRkRp((s8/usr/lib/python2.6/site-packages/nose/plugins/manager.pyRo3s   cCs;t|idƒpdS|i}|ii|i|ƒdS(Nt addSuccess(RbRRfRqRe(RReRk((s8/usr/lib/python2.6/site-packages/nose/plugins/manager.pyRq;s cCs+t|idƒpdS|ii|iƒS(Nt startTest(RbRRrRe(RRe((s8/usr/lib/python2.6/site-packages/nose/plugins/manager.pyRrAscCs+t|idƒpdS|ii|iƒS(NtstopTest(RbRRsRe(RRe((s8/usr/lib/python2.6/site-packages/nose/plugins/manager.pyRsFscCst|i|ƒS(N(R R(Rtval((s8/usr/lib/python2.6/site-packages/nose/plugins/manager.pyR?Ks(R R7R8RtostenvironRCR]RnRoRqRrRsR?(((s8/usr/lib/python2.6/site-packages/nose/plugins/manager.pyRYs       cBs)eZdZddeffZd„ZRS(shPlugin manager that loads plugins from the `nose.plugins` and `nose.plugins.0.10` entry points. snose.plugins.0.10s nose.pluginsc Cs"tt|ƒiƒddkl}h}xò|iD]ç\}}xØ||ƒD]Ê}|i|joqLnt||i.s*     i&I;&