ÿØÿàJFIFÿþ ÿÛC       ÿÛC ÿÀÿÄÿÄ"#QrÿÄÿÄ&1!A"2qQaáÿÚ ?Øy,æ/3JæÝ¹È߲؋5êXw²±ÉyˆR”¾I0ó2—PI¾IÌÚiMö¯–þrìN&"KgX:Šíµ•nTJnLK„…@!‰-ý ùúmë;ºgµŒ&ó±hw’¯Õ@”Ü— 9ñ-ë.²1<yà‚¹ïQÐU„ہ?.’¦èûbß±©Ö«Âw*VŒ) `$‰bØÔŸ’ëXÖ-ËTÜíGÚ3ð«g Ÿ§¯—Jx„–’U/ÂÅv_s(Hÿ@TñJÑãõçn­‚!ÈgfbÓc­:él[ðQe 9ÀPLbÃãCµm[5¿ç'ªjglå‡Ûí_§Úõl-;"PkÞÞÁQâ¼_Ñ^¢SŸx?"¸¦ùY騐ÒOÈ q’`~~ÚtËU¹CڒêV  I1Áß_ÿÙ k6Sc@s`dZddlZddlZddlmZyddlmZWn!ek reddlmZnXddgZddl m Z de fd YZ ydd l mZe ZWnek reZnXde fd YZd e fd YZdZdZdZdZdZdZdZedkr\ddlZejndS(sX Testing Plugins =============== The plugin interface is well-tested enough to safely unit test your use of its hooks with some level of confidence. However, there is also a mixin for unittest.TestCase called PluginTester that's designed to test plugins in their native runtime environment. Here's a simple example with a do-nothing plugin and a composed suite. >>> import unittest >>> from nose.plugins import Plugin, PluginTester >>> class FooPlugin(Plugin): ... pass >>> class TestPluginFoo(PluginTester, unittest.TestCase): ... activate = '--with-foo' ... plugins = [FooPlugin()] ... def test_foo(self): ... for line in self.output: ... # i.e. check for patterns ... pass ... ... # or check for a line containing ... ... assert "ValueError" in self.output ... def makeSuite(self): ... class TC(unittest.TestCase): ... def runTest(self): ... raise ValueError("I hate foo") ... return [TC('runTest')] ... >>> res = unittest.TestResult() >>> case = TestPluginFoo('test_foo') >>> _ = case(res) >>> res.errors [] >>> res.failures [] >>> res.wasSuccessful() True >>> res.testsRun 1 And here is a more complex example of testing a plugin that has extra arguments and reads environment variables. >>> import unittest, os >>> from nose.plugins import Plugin, PluginTester >>> class FancyOutputter(Plugin): ... name = "fancy" ... def configure(self, options, conf): ... Plugin.configure(self, options, conf) ... if not self.enabled: ... return ... self.fanciness = 1 ... if options.more_fancy: ... self.fanciness = 2 ... if 'EVEN_FANCIER' in self.env: ... self.fanciness = 3 ... ... def options(self, parser, env=os.environ): ... self.env = env ... parser.add_option('--more-fancy', action='store_true') ... Plugin.options(self, parser, env=env) ... ... def report(self, stream): ... stream.write("FANCY " * self.fanciness) ... >>> class TestFancyOutputter(PluginTester, unittest.TestCase): ... activate = '--with-fancy' # enables the plugin ... plugins = [FancyOutputter()] ... args = ['--more-fancy'] ... env = {'EVEN_FANCIER': '1'} ... ... def test_fancy_output(self): ... assert "FANCY FANCY FANCY" in self.output, ( ... "got: %s" % self.output) ... def makeSuite(self): ... class TC(unittest.TestCase): ... def runTest(self): ... raise ValueError("I hate fancy stuff") ... return [TC('runTest')] ... >>> res = unittest.TestResult() >>> case = TestFancyOutputter('test_fancy_output') >>> _ = case(res) >>> res.errors [] >>> res.failures [] >>> res.wasSuccessful() True >>> res.testsRun 1 iN(twarn(tStringIOt PluginTestertrun(tgetpidtMultiProcessFilecBsPeZdZdZdZdZdZddZdZdZ RS( s\ helper for testing multiprocessing multiprocessing poses a problem for doctests, since the strategy of replacing sys.stdout/stderr with file-like objects then inspecting the results won't work: the child processes will write to the objects, but the data will not be reflected in the parent doctest-ing process. The solution is to create file-like objects which will interact with multiprocessing in a more desirable way. All processes can write to this object, but only the creator can read. This allows the testing system to see a unified picture of I/O. cCs7t|_tj|_t|_d|_dS(Ni(Rt_MultiProcessFile__mastertManagertQueuet_MultiProcessFile__queueRt_MultiProcessFile__buffert softspace(tself((sH/opt/alt/python27/lib/python2.7/site-packages/nose/plugins/plugintest.pyt__init__~s  cCst|jkrdSddlm}ddlm}|t}x]try|jj \}}Wn|k rxPnX|dkrd}n||c|7>> import unittest >>> class SomeTest(unittest.TestCase): ... def runTest(self): ... raise ValueError("Now do something, plugin!") ... >>> unittest.TestSuite([SomeTest()]) # doctest: +ELLIPSIS ]> N(tNotImplementedError(R ((sH/opt/alt/python27/lib/python2.7/site-packages/nose/plugins/plugintest.pyt makeSuitesc Csddlm}ddlm}ddlm}d }t}|d|jd|d|d|j }|j d k r|j |_ n|j s|j }n|d|j d |d |d t|_t||_d S( s7execute the plugin on the internal test suite. i(tConfig(t TestProgram(t PluginManagertenvtstreamtpluginstargvtconfigtsuitetexitN(t nose.configR+t nose.coreR,tnose.plugins.managerR-tNonetBufferR.R0t ignoreFilest suitepathR*R1tFalsetnosetAccessDecoratortoutput(R R+R,R-R3R/tconf((sH/opt/alt/python27/lib/python2.7/site-packages/nose/plugins/plugintest.pyt _execPlugins   cCs^d|jg|_|jr1|jj|jn|jrP|jj|jn|jdS(sUruns nosetests with the specified test suite, all plugins activated. t nosetestsN(tactivateR1targstextendR;tappendRA(R ((sH/opt/alt/python27/lib/python2.7/site-packages/nose/plugins/plugintest.pytsetUps   N(R&R'R(R8RCR;RDR.R1R0R:R*RARG(((sH/opt/alt/python27/lib/python2.7/site-packages/nose/plugins/plugintest.pyRs!  R>cBs8eZdZdZdZdZdZdZRS(cCs6||_|jd|j|_|jddS(Ni(R/Rtreadt_buf(R R/((sH/opt/alt/python27/lib/python2.7/site-packages/nose/plugins/plugintest.pyR s  cCs ||jkS(N(RI(R tval((sH/opt/alt/python27/lib/python2.7/site-packages/nose/plugins/plugintest.pyt __contains__scCs t|jS(N(titerR/(R ((sH/opt/alt/python27/lib/python2.7/site-packages/nose/plugins/plugintest.pyRscCs|jS(N(RI(R ((sH/opt/alt/python27/lib/python2.7/site-packages/nose/plugins/plugintest.pyt__str__sN( R&R'R8R/RIR RKRRM(((sH/opt/alt/python27/lib/python2.7/site-packages/nose/plugins/plugintest.pyR>s    ccsg}xm|jtD]\}|j||j}| s[|jdr|jd rdj|Vg}qqW|rdj|VndS(s9a bunch of === characters is also considered a blank lines===t=tN(t splitlinesRRFtstript startswithtjoin(ttexttblocktline((sH/opt/alt/python27/lib/python2.7/site-packages/nose/plugins/plugintest.pytblankline_separated_blocks#s  & cCsftjdtjtjBtjB}g}x-t|D]}|j|jd|q6Wdj|S(NsD # 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... ^(?=\w) # a line *starts* with alphanum. .*?(?P \w+ ) # exception name (?P [:\n] .*) # the rest s"\g\n...\n\g\gRO( tretcompiletVERBOSEt MULTILINEtDOTALLRWRFtsubRS(toutt traceback_retblocksRU((sH/opt/alt/python27/lib/python2.7/site-packages/nose/plugins/plugintest.pytremove_stack_traces0s  cCs,tjdtjtjB}|jd|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(RXRYRZR[R](R^twarn_re((sH/opt/alt/python27/lib/python2.7/site-packages/nose/plugins/plugintest.pytsimplify_warningsFscCstjdd|S(NsRan (\d+ tests?) in [0-9.]+ssRan \1 in ...s(RXR](R^((sH/opt/alt/python27/lib/python2.7/site-packages/nose/plugins/plugintest.pytremove_timingsQscCs.t|}t|}t|}|jS(s6Modify nose output to make it easy to use in doctests.(RaRcRdRQ(R^((sH/opt/alt/python27/lib/python2.7/site-packages/nose/plugins/plugintest.pytmunge_nose_output_for_doctestVs   c Ossddlm}ddlm}ddlm}t}d|kr|jdg}t|t rx|d|}n|jdi}|d|d||dRWRaRcRdReRRrR&tdoctestttestmod(((sH/opt/alt/python27/lib/python2.7/site-packages/nose/plugins/plugintest.pyt`s6    ?   `    <