a
    ñ»j¥Z  ã                   @   sX   d dl Z d dlZd dlmZ d dlmZ d dlmZ G dd„ deƒZ	G dd„ deƒZ
dS )	é    N)ÚOptionConflictError)Úwarn)Útolistc                   @   s`   e Zd ZdZdZdZdZdZdZdd„ Z	ddd„Z
dd	d
„Zdd„ Zdd„ Zdd„ Zdd„ ZdS )ÚPluginaˆ  Base class for nose plugins. It's recommended but not *necessary* to
    subclass this class to create a plugin, but all plugins *must* implement
    `options(self, parser, env)` and `configure(self, options, conf)`, and
    must have the attributes `enabled`, `name` and `score`.
    The `name` attribute may contain hyphens ('-').
    Plugins should not be enabled by default.
    Subclassing Plugin (and calling the superclass methods in
    __init__, configure, and options, if you override them) will give
    your plugin some friendly default behavior:
    * A --with-$name option will be added to the command line interface
      to enable the plugin, and a corresponding environment variable
      will be used as the default value. The plugin class's docstring
      will be used as the help for this option.
    * The plugin will not be enabled unless this option is selected by
      the user.FNéd   c                 C   s:   | j d u r| jj ¡ | _ | jd u r6d| j  dd¡ | _d S )Nzenable_plugin_%sú-Ú_)ÚnameÚ	__class__Ú__name__ÚlowerÚ	enableOptÚreplace©Úself© r   ú7E:\soccer\ml_env\Lib\site-packages\nose/plugins/base.pyÚ__init__   s    

zPlugin.__init__c                 C   s   |   ||¡ dS )zˆAdd command-line options for this plugin.
        The base plugin class adds --with-$name by default,
        used to enable the plugin.N)Úadd_options©r   ÚparserÚenvr   r   r   Ú
addOptions$   s    zPlugin.addOptionsc              
   C   sl   |du rt j}z|  ||¡ d| _W nB tyf } z*td| |f tƒ d| _d| _W Y d}~n
d}~0 0 dS )z@Non-camel-case version of func name for backwards compatibility.NTz@Plugin %s has conflicting option string: %s and will be disabledF)ÚosÚenvironÚoptionsÚcan_configurer   r   ÚRuntimeWarningÚenabled)r   r   r   Úer   r   r   r   *   s    
ÿÿzPlugin.add_optionsc              	   C   sR   d| j  ¡  }| dd¡}|jd| j  d| j| |¡d| jj|  ¡ |f d� dS )	a  Register commandline options.
        Implement this method for normal options behavior with protection from
        OptionConflictErrors. If you override this method and want the default
        --with-$name option to be registered, be sure to call super().zNOSE_WITH_%sr   r   z	--with-%sÚ
store_truezEnable plugin %s: %s [%s])ÚactionÚdestÚdefaultÚhelpN)	r	   Úupperr   Ú
add_optionr   Úgetr
   r   r$   )r   r   r   Zenv_optr   r   r   r   7   s    ÿüzPlugin.optionsc                 C   s.   | j s
dS || _t|| jƒr*t|| jƒ| _dS )zºConfigure the plugin and system, based on selected options.
        The base plugin class sets the plugin to enabled if the enable option
        for the plugin (self.enableOpt) is true.N)r   ÚconfÚhasattrr   Úgetattrr   ©r   r   r(   r   r   r   Ú	configureE   s
    zPlugin.configurec                 C   s   | j jrt | j j¡S dS )z€Return help for this plugin. This will be output as the help
        section of the --with-$name option that enables the plugin.z(no help available))r
   Ú__doc__ÚtextwrapÚdedentr   r   r   r   r$   O   s    zPlugin.helpc                 C   s   t dtƒ t|ƒS )Nz9Plugin.tolist is deprecated. Use nose.util.tolist instead)r   ÚDeprecationWarningr   )r   Úvalr   r   r   r   V   s    ÿzPlugin.tolist)N)N)r   Ú
__module__Ú__qualname__r-   r   r   r   r	   Zscorer   r   r   r   r,   r$   r   r   r   r   r   r      s   


r   c                   @   sÎ  e Zd ZdZdd„ Zdd„ ZeZde_dd„ Zde_d	d
„ Z	de	_
dd„ Zde_
dd„ Zde_dd„ Zde_
dd„ Zde_dd„ Zde_dd„ Zde_dd„ Zde_dd„ Zde_dd„ Zde_dd„ Zde_dd „ Zde_d!d"„ Zd#d$„ Zd%d&„ Zd'd(„ Zde_d)d*„ Zde_de_d+e_d,d-„ Zde_de_d+e_d.d/„ Zde_d0d1„ Z de _d2d3„ Z!de!_"de!_dmd5d6„Z#de#_"dnd7d8„Z$de$_"dod9d:„Z%de%_de%_d;d<„ Z&de&_"de&_d=d>„ Z'de'_d?d@„ Z(de(_"dAdB„ Z)de)_de)_"dCdD„ Z*de*_de*_"dEdF„ Z+de+_dGdH„ Z,dIdJ„ Z-de-_dKdL„ Z.de._dMdN„ Z/de/_dOdP„ Z0de0_dQdR„ Z1dSdT„ Z2dUdV„ Z3de3_dWdX„ Z4dYdZ„ Z5de5_d[d\„ Z6d]d^„ Z7de7_d_d`„ Z8dadb„ Z9dcdd„ Z:dedf„ Z;dgdh„ Z<didj„ Z=dkdl„ Z>de>_d4S )pÚIPluginInterfacezZIPluginInterface describes the plugin API. Do not subclass or use this
    class directly.c                 O   s   t dƒ‚d S )Nz0IPluginInterface class is for documentation only)Ú	TypeError)ÚclsÚargÚkwr   r   r   Ú__new___   s    zIPluginInterface.__new__c                 C   s   dS )zÅCalled to allow plugin to register command-line options with the
        parser. DO NOT return a value from this method unless you want to stop
        all other plugins from setting their options.Nr   r   r   r   r   r   b   s    zIPluginInterface.addOptionsTc                 C   s   dS )z“Called when a deprecated test is seen. DO NOT return a value
        unless you want to stop other plugins from seeing the deprecated
        test.Nr   ©r   Útestr   r   r   ÚaddDeprecatedk   s    zIPluginInterface.addDeprecatedc                 C   s   dS )a?  Called when a test raises an uncaught exception. DO NOT return a
        value unless you want to stop other plugins from seeing that the
        test has raised an error.
        :param test: the test case
        :type test: :class:`nose.case.Test`
        :param err: sys.exc_info() tuple
        :type err: 3-tuple Nr   ©r   r;   Úerrr   r   r   ÚaddErrors   s    zIPluginInterface.addErrorc                 C   s   dS )a  Called when a test fails. DO NOT return a value unless you
        want to stop other plugins from seeing that the test has failed.
        :param test: the test case
        :type test: :class:`nose.case.Test`
        :param err: 3-tuple
        :type err: sys.exc_info() tuple Nr   r=   r   r   r   Ú
addFailure   s    zIPluginInterface.addFailurec                 C   s   dS )z€Called when a test is skipped. DO NOT return a value unless
        you want to stop other plugins from seeing the skipped test.Nr   r:   r   r   r   ÚaddSkipŠ   s    zIPluginInterface.addSkipc                 C   s   dS )zÌCalled when a test passes. DO NOT return a value unless you
        want to stop other plugins from seeing the passing test.
        :param test: the test case
        :type test: :class:`nose.case.Test` Nr   r:   r   r   r   Ú
addSuccess‘   s    zIPluginInterface.addSuccessc                 C   s   dS )z”Called after a context (generally a module) has been
        lazy-loaded, imported, setup, had its tests loaded and
        executed, and torn down.Nr   r   r   r   r   ÚafterContextš   s    zIPluginInterface.afterContextc                 C   s   dS )z«Called after all tests have been loaded from directory at path
        and run.
        :param path: the directory that has finished processing
        :type path: string Nr   ©r   Úpathr   r   r   ÚafterDirectory¢   s    zIPluginInterface.afterDirectoryc                 C   s   dS )a  Called after module is imported from filename. afterImport
        is called even if the import failed.
        :param filename: The file that was loaded
        :type filename: string
        :param module: The name of the module
        :type module: string Nr   ©r   ÚfilenameÚmoduler   r   r   ÚafterImport«   s    zIPluginInterface.afterImportc                 C   s   dS )z¤Called after the test has been run and the result recorded
        (after stopTest).
        :param test: the test case
        :type test: :class:`nose.case.Test` Nr   r:   r   r   r   Ú	afterTest¶   s    zIPluginInterface.afterTestc                 C   s   dS )aà  Called before a context (generally a module) is
        examined. Because the context is not yet loaded, plugins don't
        get to know what the context is; so any context operations
        should use a stack that is pushed in `beforeContext` and popped
        in `afterContext` to ensure they operate symmetrically.
        `beforeContext` and `afterContext` are mainly useful for tracking
        and restoring global state around possible changes from within a
        context, whatever the context may be. If you need to operate on
        contexts themselves, see `startContext` and `stopContext`, which
        are passed the context in question, but are called after
        it has been loaded (imported in the module case).Nr   r   r   r   r   ÚbeforeContext¿   s    zIPluginInterface.beforeContextc                 C   s   dS )zxCalled before tests are loaded from directory at path.
        :param path: the directory that is about to be processed Nr   rD   r   r   r   ÚbeforeDirectoryÏ   s    z IPluginInterface.beforeDirectoryc                 C   s   dS )z¿Called before module is imported from filename.
        :param filename: The file that will be loaded
        :param module: The name of the module found in file
        :type module: string Nr   rG   r   r   r   ÚbeforeImportÖ   s    zIPluginInterface.beforeImportc                 C   s   dS )z�Called before the test is run (before startTest).
        :param test: the test case
        :type test: :class:`nose.case.Test` Nr   r:   r   r   r   Ú
beforeTestß   s    zIPluginInterface.beforeTestc                 C   s   dS )zqCalled before any tests are collected or run. Use this to
        perform any setup needed before testing begins.Nr   r   r   r   r   Úbeginç   s    zIPluginInterface.beginc                 C   s   dS )aZ  Called after the command line has been parsed, with the
        parsed options and the config container. Here, implement any
        config storage or changes to state or operation that are set
        by command line options.
        DO NOT return a value from this method unless you want to
        stop all other plugins from being configured.Nr   r+   r   r   r   r,   ì   s    zIPluginInterface.configurec                 C   s   dS )zõCalled after all report/plugin output has been sent to the stream.
        Use this to print final test results or perform final cleanup.
        Return None to allow other plugins to continue printing.
        :param result: test result object Nr   ©r   Úresultr   r   r   Úfinalizeõ   s    zIPluginInterface.finalizec                 C   s   dS )z¥Return a test description.
        Called by :meth:`nose.case.Test.shortDescription`.
        :param test: the test case
        :type test: :class:`nose.case.Test` Nr   r:   r   r   r   ÚdescribeTestü   s    zIPluginInterface.describeTestc                 C   s   dS )aR  Called in result.addError, before plugin.addError. If you
        want to replace or modify the error tuple, return a new error
        tuple, otherwise return err, the original error tuple.
        :param test: the test case
        :type test: :class:`nose.case.Test`
        :param err: sys.exc_info() tuple
        :type err: 3-tuple Nr   r=   r   r   r   ÚformatError  s    zIPluginInterface.formatError)TFc                 C   s   dS )aV  Called in result.addFailure, before plugin.addFailure. If you
        want to replace or modify the error tuple, return a new error
        tuple, otherwise return err, the original error tuple.
        :param test: the test case
        :type test: :class:`nose.case.Test`
        :param err: sys.exc_info() tuple
        :type err: 3-tuple Nr   r=   r   r   r   ÚformatFailure  s    zIPluginInterface.formatFailurec                 C   s   dS )a  Called on addError. To handle the error yourself and prevent normal
        error processing, return a true value.
        :param test: the test case
        :type test: :class:`nose.case.Test`
        :param err: sys.exc_info() tuple
        :type err: 3-tuple Nr   r=   r   r   r   ÚhandleError!  s    zIPluginInterface.handleErrorc                 C   s   dS )a  Called on addFailure. To handle the failure yourself and
        prevent normal failure processing, return a true value.
        :param test: the test case
        :type test: :class:`nose.case.Test`
        :param err: sys.exc_info() tuple
        :type err: 3-tupleNr   r=   r   r   r   ÚhandleFailure,  s    zIPluginInterface.handleFailurec                 C   s   dS )a,  Return iterable of tests from a directory. May be a
        generator. Each item returned must be a runnable
        unittest.TestCase (or subclass) instance or suite instance.
        Return None if your plugin cannot collect any tests from directory.
        :param path: The path to the directory.Nr   rD   r   r   r   ÚloadTestsFromDir7  s    z!IPluginInterface.loadTestsFromDirNc                 C   s   dS )ag  Return iterable of tests in a module. May be a
        generator. Each item returned must be a runnable
        unittest.TestCase (or subclass) instance.
        Return None if your plugin cannot
        collect any tests from module.
        :param module: The module object
        :type module: python module
        :param path: the module path to search Nr   )r   rI   rE   r   r   r   ÚloadTestsFromModuleB  s    	z$IPluginInterface.loadTestsFromModulec                 C   s   dS )a  Return tests in this file or module. Return None if you are not able
        to load any tests, or an iterable if you are. May be a generator.
        :param name: The test name. May be a file or module name plus a test
            callable. Use split_test_name to split into parts. Or it might
            be some crazy name of your own devising, in which case, do
            whatever you want.
        :param module: Module from which the name is to be loaded
        :param importPath: Path from which file (python module) was found Nr   )r   r	   rI   Z
importPathr   r   r   ÚloadTestsFromNameO  s    	z"IPluginInterface.loadTestsFromNamec                 C   s   dS )a„  Return a tuple of (tests loaded, remaining names). Return
        None if you are not able to load any tests. Multiple plugins
        may implement loadTestsFromNames; the remaining name list from
        each will be passed to the next as input.
        :param names: List of test names.
        :type names: iterable
        :param module: Module from which the names are to be loaded Nr   )r   ÚnamesrI   r   r   r   ÚloadTestsFromNames\  s    z#IPluginInterface.loadTestsFromNamesc                 C   s   dS )a:  Return tests in this file. Return None if you are not
        interested in loading any tests, or an iterable if you are and
        can load some. May be a generator. *If you are interested in
        loading tests from the file and encounter no errors, but find
        no tests, yield False or return [False].* Nr   )r   rH   r   r   r   ÚloadTestsFromFilei  s    z"IPluginInterface.loadTestsFromFilec                 C   s   d S ©Nr   rD   r   r   r   ÚloadTestsFromPatht  s    z"IPluginInterface.loadTestsFromPathc                 C   s   dS )zèReturn tests in this test case class. Return None if you are not
        able to load any tests, or an iterable if you are. May be a generator.
        :param cls: Test class. Must be subclass of :class:`unittest.TestCase`.
        Nr   ©r   r6   r   r   r   ÚloadTestsFromTestCasey  s    z&IPluginInterface.loadTestsFromTestCasec                 C   s   dS )a  Return tests in this test class. Class will *not* be a
        unittest.TestCase subclass. Return None if you are not able to
        load any tests, an iterable if you are. May be a generator.
        :param cls: Class. Must not be subclass of :class:`unittest.TestCase`.
        Nr   ra   r   r   r   ÚloadTestsFromTestClass‚  s    z'IPluginInterface.loadTestsFromTestClassc                 C   s   dS )aª  Given an object and its parent, return or yield one or more
        test cases. Each test must be a unittest.TestCase (or subclass)
        instance. This is called before default test loading to allow
        plugins to load an alternate test case or cases for an
        object. May be a generator.
        :param obj: The object to be made into a test
        :param parent: The parent of obj (eg, for a method, the class) Nr   )r   ÚobjÚparentr   r   r   ÚmakeTest�  s    zIPluginInterface.makeTestc                 C   s   dS )am  Called to allow plugin to register command line
        options with the parser.
        DO NOT return a value from this method unless you want to stop
        all other plugins from setting their options.
        :param parser: options parser instance
        :type parser: :class:`ConfigParser.ConfigParser`
        :param env: environment, default is os.environ Nr   r   r   r   r   r   š  s    zIPluginInterface.optionsc                 C   s   dS )a|  Called before the test is run by the test runner. Please
        note the article *the* in the previous sentence: prepareTest
        is called *only once*, and is passed the test case or test
        suite that the test runner will execute. It is *not* called
        for each individual test case. If you return a non-None value,
        that return value will be run as the test. Use this hook to
        wrap or decorate the test with another function. If you need
        to modify or wrap individual test cases, use `prepareTestCase`
        instead.
        :param test: the test case
        :type test: :class:`nose.case.Test` Nr   r:   r   r   r   ÚprepareTest¦  s    zIPluginInterface.prepareTestc                 C   s   dS )aÒ  Prepare or wrap an individual test case. Called before
        execution of the test. The test passed here is a
        nose.case.Test instance; the case to be executed is in the
        test attribute of the passed case. To modify the test to be
        run, you should return a callable that takes one argument (the
        test result object) -- it is recommended that you *do not*
        side-effect the nose.case.Test instance you have been passed.
        Keep in mind that when you replace the test callable you are
        replacing the run() method of the test case -- including the
        exception handling and result calls, etc.
        :param test: the test case
        :type test: :class:`nose.case.Test` Nr   r:   r   r   r   ÚprepareTestCase´  s    z IPluginInterface.prepareTestCasec                 C   s   dS )a?  Called before tests are loaded. To replace the test loader,
        return a test loader. To allow other plugins to process the
        test loader, return None. Only one plugin may replace the test
        loader. Only valid when using nose.TestProgram.
        :param loader: :class:`nose.loader.TestLoader` instance Nr   )r   Úloaderr   r   r   ÚprepareTestLoaderÅ  s    z"IPluginInterface.prepareTestLoaderc                 C   s   dS )a9  Called before the first test is run. To use a different
        test result handler for all tests than the given result,
        return a test result handler. NOTE however that this handler
        will only be seen by tests, that is, inside of the result
        proxy system. The TestRunner and TestProgram -- whether nose's
        or other -- will continue to see the original result
        handler. For this reason, it is usually better to monkeypatch
        the result (for instance, if you want to handle some
        exceptions in a unique way). Only one plugin may replace the
        result, but many may monkeypatch it. If you want to
        monkeypatch and stop other plugins from doing so, monkeypatch
        and return the patched result.
        :param result: :class:`nose.result.TextTestResult` instance Nr   rQ   r   r   r   ÚprepareTestResultÏ  s    z"IPluginInterface.prepareTestResultc                 C   s   dS )a	  Called before tests are run. To replace the test runner,
        return a test runner. To allow other plugins to process the
        test runner, return None. Only valid when using nose.TestProgram.
        :param runner: :class:`nose.core.TextTestRunner` instance Nr   )r   Úrunnerr   r   r   ÚprepareTestRunnerá  s    z"IPluginInterface.prepareTestRunnerc                 C   s   dS )a)  Called after all error output has been printed. Print your
        plugin's report to the provided stream. Return None to allow
        other plugins to print reports, any other value to stop them.
        :param stream: stream object; send your output here
        :type stream: file-like object Nr   ©r   Ústreamr   r   r   Úreportê  s    zIPluginInterface.reportc                 C   s   dS )a[  Called before test output begins. To direct test output to a
        new stream, return a stream object, which must implement a
        `write(msg)` method. If you only want to note the stream, not
        capture or redirect it, then return None.
        :param stream: stream object; send your output here
        :type stream: file-like object Nr   rn   r   r   r   ÚsetOutputStreamò  s    z IPluginInterface.setOutputStreamc                 C   s   dS )a&  Called before context setup and the running of tests in the
        context. Note that tests have already been *loaded* from the
        context before this call.
        :param context: the context about to be setup.
            May be a module, class, or any other object that contains tests.Nr   ©r   Úcontextr   r   r   ÚstartContextû  s    zIPluginInterface.startContextc                 C   s   dS )zÏCalled before each test is run. DO NOT return a value unless
        you want to stop other plugins from seeing the test start.
        :param test: the test case
        :type test: :class:`nose.case.Test` Nr   r:   r   r   r   Ú	startTest  s    zIPluginInterface.startTestc                 C   s   dS )zÞCalled after the tests in a context have run and the
        context has been torn down.
        :param context: the context that has been torn down.
        May be a module, class, or any other object that contains tests.Nr   rr   r   r   r   ÚstopContext  s    zIPluginInterface.stopContextc                 C   s   dS )zÙCalled after each test is run. DO NOT return a value unless
        you want to stop other plugins from seeing that the test has stopped.
        :param test: the test case
        :type test: :class:`nose.case.Test` Nr   r:   r   r   r   ÚstopTest  s    zIPluginInterface.stopTestc                 C   s   dS )z�Return a short test name. Called by `nose.case.Test.__str__`.
        :param test: the test case
        :type test: :class:`nose.case.Test` Nr   r:   r   r   r   ÚtestName  s    zIPluginInterface.testNamec                 C   s   dS )zÆReturn true if you want the main test selector to collect
        tests from this class, false if you don't, and None if you don't care.
        :param cls: The class being examined by the selector Nr   ra   r   r   r   Ú	wantClass$  s    zIPluginInterface.wantClassc                 C   s   dS )zÉReturn true if you want test collection to descend into this
        directory, false if you do not, and None if you don't care.
        :param dirname: Full path to dir being examined by the selector Nr   )r   Údirnamer   r   r   ÚwantDirectory*  s    zIPluginInterface.wantDirectoryc                 C   s   dS )z·Return true if you want to collect tests from this file,
        false if you do not and None if you don't care.
        :param file: Full path to file being examined by the selector Nr   )r   Úfiler   r   r   ÚwantFile0  s    zIPluginInterface.wantFilec                 C   s   dS )zÊReturn true to collect this function as a test, false to
        prevent it from being collected, and None if you don't care.
        :param function: The function object being examined by the selector Nr   )r   Úfunctionr   r   r   ÚwantFunction6  s    zIPluginInterface.wantFunctionc                 C   s   dS )zéReturn true to collect this method as a test, false to
        prevent it from being collected, and None if you don't care.
        :param method: The method object being examined by the selector
        :type method: unbound method Nr   )r   Úmethodr   r   r   Ú
wantMethod<  s    zIPluginInterface.wantMethodc                 C   s   dS )a  Return true if you want to collection to descend into this
        module, false to prevent the collector from descending into the
        module, and None if you don't care.
        :param module: The module object being examined by the selector
        :type module: python module Nr   ©r   rI   r   r   r   Ú
wantModuleC  s    zIPluginInterface.wantModulec                 C   s   d S r_   r   r‚   r   r   r   ÚwantModuleTestsK  s    z IPluginInterface.wantModuleTests)N)NN)N)?r   r2   r3   r-   r9   r   r   Ú
deprecatedr<   r?   Úchangedr@   rA   rB   rC   Ú_newrF   rJ   rK   rL   rM   rN   rO   rP   r,   rS   rT   rU   Z	chainableZstatic_argsrV   rW   rX   rY   Z
generativerZ   r[   r]   r^   r`   rb   rc   rf   r   rg   rh   rj   rk   rm   rp   rq   rt   ru   rv   rw   rx   ry   r{   r}   r   r�   rƒ   r„   r   r   r   r   r4   \   sÈ   
			

		





	r4   )r   r.   Úoptparser   Úwarningsr   Z	nose.utilr   Úobjectr   r4   r   r   r   r   Ú<module>   s   T