Ñò Æ^mGc@s¨dZddklZddkZddkZddkZddkZddkZddkl Z ddk l Z l Z ddk lZddklZlZlZddklZdd klZdd klZlZeid ƒZeid d fjZdddddddgZdeifd„ƒYZdei fd„ƒYZ e Z!Z"d„Z#dd„Z$d„Z%dfd„ƒYZ&e&Z'e(djo e"ƒndS(s,Implements nose test program and collector. iÿÿÿÿ(t generatorsN(twarn(tConfigtall_config_files(tdefaultTestLoader(t PluginManagertDefaultPluginManagertRestrictedPluginManager(tTextTestResult(tFinalizingSuiteWrapper(tisclassttolists nose.coreiit TestProgramtmaintruntrun_exitt runmodulet collectortTextTestRunnercBs8eZdZeidddd„Zd„Zd„ZRS(sÉTest runner that uses nose's TextTestResult to enable errorClasses, as well as providing hooks for plugins to override or replace the test output stream, results, and the test case itself. icCs@|djo tƒ}n||_tii||||ƒdS(N(tNoneRtconfigtunittestRt__init__(tselftstreamt descriptionst verbosityR((s-/usr/lib/python2.6/site-packages/nose/core.pyR!s   cCst|i|i|i|iƒS(N(RRRRR(R((s-/usr/lib/python2.6/site-packages/nose/core.pyt _makeResult)s cCs½|iii|ƒ}|dj o |}n|iii|iƒ}|dj o ||_n|iƒ}tiƒ}||ƒtiƒ}|iƒ|i ||ƒ|iii |ƒ|S(saOverrides to provide plugin hooks and defer all output to the test result class. N( Rtpluginst prepareTestRtsetOutputStreamRRttimet printErrorst printSummarytfinalize(Rttesttwrappertwrappedtresulttstarttstop((s-/usr/lib/python2.6/site-packages/nose/core.pyR/s         N( t__name__t __module__t__doc__tsyststderrRRRR(((s-/usr/lib/python2.6/site-packages/nose/core.pyRs    c BskeZdZdZd dd d d d d d ed d„ Zd d„Zd„Zd„Z d„Z d„Z RS( sEusage: %prog [options] [names] nose provides extended test discovery and running features for unittest. nose collects tests automatically from python source files, directories and packages found in its working directory (which defaults to the current working directory). Any python source file, directory or package that matches the testMatch regular expression (by default: (?:^|[\b_\.-])[Tt]est) will be collected as a test (or source for collection of tests). In addition, all other packages found in the working directory will be examined for python source files or directories that match testMatch. Package discovery descends all the way down the tree, so package.tests and package.sub.tests and package.sub.sub2.tests will all be collected. Within a test directory or package, any python source file matching testMatch will be examined for test cases. Within a test module, functions and classes whose names match testMatch and TestCase subclasses with any name will be loaded and executed as tests. Tests may use the assert keyword or raise AssertionErrors to indicate test failure. TestCase subclasses may do the same or use the various TestCase methods available. Selecting Tests --------------- To specify which tests to run, pass test names on the command line: %prog only_test_this.py Test names specified may be file or module names, and may optionally indicate the test case to run by separating the module or file name from the test case name with a colon. Filenames may be relative or absolute. Examples: %prog test.module %prog another.test:TestCase.test_method %prog a.test:TestCase %prog /path/to/test/file.py:test_function You may also change the working directory where nose looks for tests, use the -w switch: %prog -w /path/to/tests Note however that support for multiple -w arguments is deprecated in this version and will be removed in a future release, since as of nose 0.10 you can get the same behavior by specifying the target directories *without* the -w switch: %prog /path/to/tests /another/path/to/tests Further customization of test selection and loading is possible through the use of plugins. Test result output is identical to that of unittest, except for the additional features (error classes, and plugin-supplied features such as output capture and assert introspection) detailed in the options below. Configuration ------------- In addition to passing command-line options, you may also put configuration options in a .noserc or nose.cfg file in your home directory. These are standard .ini-style config files. Put your nosetests configuration in a [nosetests] section. Options are the same as on the command line, with the -- prefix removed. For options that are simple switches, you must supply a value: [nosetests] verbosity=3 with-doctest=1 All configuration files that are found will be loaded and their options combined. Using Plugins ------------- There are numerous nose plugins available via easy_install and elsewhere. To use a plugin, just install it. The plugin will add command line options to nosetests. To verify that the plugin is installed, run: nosetests --plugins You can add -v or -vv to that command to show more information about each plugin. If you are running nose.main() or nose.run() from a script, you can specify a list of plugins to use by passing a list of plugins with the plugins keyword argument. 0.9 plugins ----------- nose 0.10 can use SOME plugins that were written for nose 0.9. The default plugin manager inserts a compatibility wrapper around 0.9 plugins that adapts the changed plugin api calls. However, plugins that access nose internals are likely to fail, especially if they attempt to access test case or test suite classes. For example, plugins that try to determine if a test passed to startTest is an individual test or a suite will fail, partly because suites are no longer passed to startTest and partly because it's likely that the plugin is trying to find out if the test is an instance of a class that no longer exists. it.c CsŠ|djo ti}n|djo|i|| ƒ}n||_||_| |_tii |d|d|d|d|d|ƒdS(s9 Collect and run tests, returning success or failure. The arguments to __init__ are the same as to `main()` and `run()`: * module: All tests are in this module (default: None) * defaultTest: Tests to load (default: '.') * argv: Command line arguments (default: None; sys.argv is read) * testRunner: Test runner instance (default: None) * testLoader: Test loader instance (default: None) * env: Environment; ignored if config is provided (default: None; os.environ is read) * config: `nose.config.Config`_ instance (default: None) * suite: Suite or list of tests to run (default: None). Passing a suite or lists of tests will bypass all test discovery and loading. *ALSO NOTE* that if you pass a unittest.TestSuite instance as the suite, context fixtures at the class, module and package level will not be used, and many plugin hooks will not be called. If you want normal nose behavior, either pass a list of tests, or a fully-configured `nose.suite.ContextSuite`_. * exit: Exit after running tests and printing report (default: True) * plugins: List of plugins to use; ignored if config is provided (default: load plugins with DefaultPluginManager) tmodulet defaultTesttargvt testRunnert testLoaderN( Rtostenviront makeConfigRtsuitetexitRR R( RR/R0R1R2R3tenvRR7R8R((s-/usr/lib/python2.6/site-packages/nose/core.pyR¶s       cCsEtƒ}|otd|ƒ}n tƒ}td|d|d|ƒS(sSLoad a Config, pre-filled with user config files if any are found. RR9tfiles(RRRR(RR9Rt cfg_filestmanager((s-/usr/lib/python2.6/site-packages/nose/core.pyR6Ýs   cCsà|ii|dtiƒtid|iƒ|iiioOddkl }t i t _ dt iit idƒ|fGHt idƒn|iiio|iƒt idƒn|id jotd|iƒ|_n-t|iƒo|id|iƒ|_n|iii|iƒ}|d j o ||_ntid|iƒ|iio|ii|_nt|iƒ|_tid |iƒtid |iƒ|iid j ot i|iiƒn|iƒd S( s>Parse argv and env and configure running environment. tdocs configured %siÿÿÿÿ(t __version__s %s version %siRstest loader is %ssdefaultTest %ssTest names are %sN(Rt configureR R+tlogtdebugtoptionstversiontnoseR>R,t __stdout__tstdoutR4tpathtbasenameR1R8t showPluginsR3RRR RtprepareTestLoadert testNamesR R0t workingDirtchdirt createTests(RR1R>t plug_loader((s-/usr/lib/python2.6/site-packages/nose/core.pyt parseArgsés4 "    cCs[tid|iƒ|idj o|ii|iƒ|_n|ii|iƒ|_dS(sÑCreate the tests to run. If a self.suite is set, then that suite will be used. Otherwise, tests will be loaded from the given test names (self.testNames) using the test loader. screateTests called with %sN( R@RAR7RR3t suiteClassR#tloadTestsFromNamesRK(R((s-/usr/lib/python2.6/site-packages/nose/core.pyRNscCsÊtidƒ|idjo1td|iid|iid|iƒ|_n|iii |iƒ}|dj o ||_n|ii |i ƒ}|i ƒ|_ |ioti|i ƒn|i S(soRun Tests. Returns true on success, false on failure, and sets self.success to the same value. srunTests calledRRRN(R@RAR2RRRRRRtprepareTestRunnerRR#t wasSuccessfultsuccessR8R,(Rt plug_runnerR&((s-/usr/lib/python2.6/site-packages/nose/core.pytrunTestss     c Cs<ddk}ddd„ƒY}|ii}|iiiƒxú|iiD]ì}d|iGH|djoÍd|iGHdi|i|i ƒi ƒd d d d ƒƒGH|d jo€Hd GH|ƒ}|i |ƒxa|i D]R\}}ddi|ƒGH|o-di|i|i ƒd dd dƒƒGHqÕqÕWnHqHqHWdS(s)Print list of available plugins. iÿÿÿÿNt DummyParsercBseZd„Zd„ZRS(cSs g|_dS(N(RB(R((s-/usr/lib/python2.6/site-packages/nose/core.pyR6sc_s&|ii||iddƒfƒdS(Nthelpt(RBtappendtpop(Rtargtkw((s-/usr/lib/python2.6/site-packages/nose/core.pyt add_option8s(R)R*RR_(((s-/usr/lib/python2.6/site-packages/nose/core.pyRX5s s Plugin %sis score: %ss tinitial_indents tsubsequent_indentis Options:s %ss, s (( ttextwrapRRRtsorttnametscoretjointwrapRYtstript addOptionsRB(RRbRXtvtptparsertoptsRY((s-/usr/lib/python2.6/site-packages/nose/core.pyRI0s4           N( R)R*R+RRtTrueRR6RPRNRWRI(((s-/usr/lib/python2.6/site-packages/nose/core.pyR Fsm  % '  cOst|ds8      *ÿ