Ńņ ā÷Gc @s dZddkZddkZddklZyddklZWn#ej oddklZnXddgZde fd„ƒYZ de fd „ƒYZ d „Z d „Z d „Zd „Zd„Zd„Zd„ZedjoddkZeiƒndS(s> Plugin tester ------------- Utilities for testing plugins. i’’’’N(twarn(tStringIOt PluginTestertruncBsSeZdZdZdZdZhZdZgZ dZ d„Z d„Z d„Z RS(szA mixin for testing nose plugins in their runtime environment. Subclass this and mix in unittest.TestCase to run integration/functional tests on your plugin. When setUp() is called, the stub test suite is executed with your plugin so that during an actual test you can inspect the artifacts of how your plugin interacted with the stub test suite. Class Variables --------------- - activate - the argument to send nosetests to activate the plugin - suitepath - if set, this is the path of the suite to test. otherwise, you will need to use the hook, makeSuite() - plugins - the list of plugins to make available during the run. Note that this does not mean these plugins will be *enabled* during the run -- only the plugins enabled by the activate argument or other settings in argv or env will be enabled. - args - a list of arguments to add to the nosetests command, in addition to the activate argument - env - optional dict of environment variables to send nosetests cCs t‚dS(s»returns a suite object of tests to run (unittest.TestSuite()) If self.suitepath is None, this must be implemented. The returned suite object will be executed with all plugins activated. It may return None. Here is an example of a basic suite object you can return :: >>> import unittest >>> class SomeTest(unittest.TestCase): ... def runTest(self): ... raise ValueError("Now do something, plugin!") ... >>> unittest.TestSuite([SomeTest()]) # doctest: +ELLIPSIS ]> N(tNotImplementedError(tself((s;/usr/lib/python2.6/site-packages/nose/plugins/plugintest.pyt makeSuiteAsc CsŻddkl}ddkl}ddkl}d }tƒ}|d|id|d|d|i ƒƒ}|i d j o|i |_ n|i p|i ƒ}n|d|i d |d |d tƒ|_t|ƒ|_d S( s7execute the plugin on the internal test suite. i’’’’(tConfig(t TestProgram(t PluginManagertenvtstreamtpluginstargvtconfigtsuitetexitN(t nose.configRt nose.coreRtnose.plugins.managerR tNoneRR R t ignoreFilest suitepathRR tFalsetnosetAccessDecoratortoutput(RRRR RR tconf((s;/usr/lib/python2.6/site-packages/nose/plugins/plugintest.pyt _execPluginUs   cCsbd|ig|_|io|ii|iƒn|io|ii|iƒn|iƒdS(sVruns nosetests with the specified test suite, all plugins activated. t nosetestsN(tactivateR targstextendRtappendR(R((s;/usr/lib/python2.6/site-packages/nose/plugins/plugintest.pytsetUpjs   N(t__name__t __module__t__doc__RRRRR R R RRRR"(((s;/usr/lib/python2.6/site-packages/nose/plugins/plugintest.pyRs#  RcBs8eZdZdZd„Zd„Zd„Zd„ZRS(cCs6||_|idƒ|iƒ|_|idƒdS(Ni(R tseektreadt_buf(RR ((s;/usr/lib/python2.6/site-packages/nose/plugins/plugintest.pyt__init__zs  cCs ||ijS(N(R((Rtval((s;/usr/lib/python2.6/site-packages/nose/plugins/plugintest.pyt __contains__scCs|iS(N(R (R((s;/usr/lib/python2.6/site-packages/nose/plugins/plugintest.pyt__iter__scCs|iS(N(R((R((s;/usr/lib/python2.6/site-packages/nose/plugins/plugintest.pyt__str__ƒsN( R#R$RR R(R)R+R,R-(((s;/usr/lib/python2.6/site-packages/nose/plugins/plugintest.pyRws    ccsog}xI|itƒD]8}|i|ƒ|iƒpdi|ƒVg}qqW|odi|ƒVndS(Nt(t splitlinestTrueR!tstriptjoin(ttexttblocktline((s;/usr/lib/python2.6/site-packages/nose/plugins/plugintest.pytblankline_separated_blocks‡s  cCsftidtitiBtiBƒ}g}x-t|ƒD]}|i|id|ƒƒq6Wdi|ƒS(Nsß # Grab the traceback header. Different versions of Python have # said different things on the first traceback line. ^(?P Traceback\ \( (?: most\ recent\ call\ last | innermost\ last ) \) : ) \s* $ # toss trailing whitespace on the header. (?P .*?) # don't blink: absorb stuff until... ^ (?P \w+ .*) # a line *starts* with alphanum. s\g\n...\n\gR.( tretcompiletVERBOSEt MULTILINEtDOTALLR6R!tsubR2(toutt traceback_retblocksR4((s;/usr/lib/python2.6/site-packages/nose/plugins/plugintest.pytremove_stack_traces’s  cCs,tidtitiBƒ}|id|ƒS(Nsü # Cut the file and line no, up to the warning name ^.*:\d+:\s (?P\w+): \s+ # warning category (?P.+) $ \n? # warning message ^ .* $ # stack frame s\g: \g(R7R8R9R:R<(R=twarn_re((s;/usr/lib/python2.6/site-packages/nose/plugins/plugintest.pytsimplify_warnings¦scCstidd|ƒS(NsRan (\d+ tests?) in [0-9.]+ssRan \1 in ...s(R7R<(R=((s;/usr/lib/python2.6/site-packages/nose/plugins/plugintest.pytremove_timings±scCs.t|ƒ}t|ƒ}t|ƒ}|iƒS(s6Modify nose output to make it easy to use in doctests.(R@RBRCR1(R=((s;/usr/lib/python2.6/site-packages/nose/plugins/plugintest.pytmunge_nose_output_for_doctest¶s   c Os}ddkl}ddkl}ddkl}tƒ}d|jod|idgƒ}t|t ƒo|d|ƒ}n|idhƒ}|d|d|ƒ|ds(   b    <