$48 GRAYBYTE WORDPRESS FILE MANAGER $20

SERVER : premium201.web-hosting.com #1 SMP Wed Mar 26 12:08:09 UTC 2025
SERVER IP : 104.21.15.130 | ADMIN IP 216.73.216.174
OPTIONS : CRL = ON | WGT = ON | SDO = OFF | PKEX = OFF
DEACTIVATED : NONE

/opt/hc_python/lib/python3.12/site-packages/nose/plugins/__pycache__/

HOME
Current File : /opt/hc_python/lib/python3.12/site-packages/nose/plugins/__pycache__//plugintest.cpython-312.pyc
�

H��g�4��6�dZddlZddlZddlmZ	ddlmZddgZddl	m
Z
Gd�d	e�Z	dd
l
mZeZGd�de�ZGd�d
e�Zd�Zd�Zd�Zd�Zd�Zd�Zd�Zedk(rddlZej6�yy#e$r	ddlmZY�rwxYw#e$reZY�awxYw)a_
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

�N)�warn)�StringIO�PluginTester�run)�getpidc�<�eZdZdZd�Zd�Zd�Zd�Zd
d�Zd�Z	d�Z
y	)�MultiProcessFilea\
    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.
    c��t�|_t�j�|_t�|_d|_y�Nr)r�_MultiProcessFile__master�Manager�Queue�_MultiProcessFile__queuer�_MultiProcessFile__buffer�	softspace��selfs �F/opt/hc_python/lib/python3.12/site-packages/nose/plugins/plugintest.py�__init__zMultiProcessFile.__init__~s-�����
��y���(��� �
��
����c�>�t�|jk7ryddlm}ddlm}|t�}		|jj�\}}|dk(rd}||xx|z
cc<�3#|$rYnwxYwt|�D] }|jj||��"y)Nr)�Empty)�defaultdict�)g}Ô%�I�T)rr�queuer�collectionsr�strr�
get_nowait�sortedr�write)rrr�cache�pid�datas      r�bufferzMultiProcessFile.buffer�s����8�t�}�}�$���+��C� ���
� �L�L�3�3�5�	��T��b�y�!���#�J�$��J����
��
���%�=�C��M�M����s��-�!s�A%�%A-�,A-c�l�ddlm}|�j}|jj	||f�y)Nr)�current_process)�multiprocessingr&�	_identityr�put)rr#r&r"s    rr zMultiProcessFile.write�s+��	4���)�)�������#�t��%rc�:�|j�|jS)zgetattr doesn't work for iter())r$rrs r�__iter__zMultiProcessFile.__iter__�s�����
��}�}�rc�Z�|j�|jj||�S�N)r$r�seek)r�offset�whences   rr.zMultiProcessFile.seek�s"�����
��}�}�!�!�&�&�1�1rc�V�|j�|jj�Sr-)r$r�getvaluers rr2zMultiProcessFile.getvalue�s�����
��}�}�%�%�'�'rc�.�t|j|�Sr-)�getattrr)r�attrs  r�__getattr__zMultiProcessFile.__getattr__�s���t�}�}�d�+�+rN)r)�__name__�
__module__�__qualname__�__doc__rr$r r+r.r2r6rrrr	r	ns*����.�(&��2�(�,rr	)r
c�>�eZdZdZdZdZdZiZdZgZ	dZ
d�Zd�Zd�Z
y)ra%A 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.

    - 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

    Nc��t�)a�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
            <unittest...TestSuite tests=[<...SomeTest testMethod=runTest>]>

        )�NotImplementedErrorrs r�	makeSuitezPluginTester.makeSuite�s
��$"�!rc�T�ddlm}ddlm}ddlm}d}t
�}||j|||j����}|j�|j|_	|js|j�}||j||d�	�|_
t|�|_y)
z7execute the plugin on the internal test suite.
        r��Config)�TestProgram��
PluginManagerN��plugins)�env�streamrFF)�argv�config�suite�exit)�nose.configrA�	nose.corerB�nose.plugins.managerrD�BufferrGrF�ignoreFiles�	suitepathr>rI�nose�AccessDecorator�output)rrArBrDrKrH�confs       r�_execPluginzPluginTester._execPlugin�s���	'�)�6�������$�(�(�#�+�D�L�L�A�C�����'�#�/�/�D���~�~��N�N�$�E��T�Y�Y�t�5�%*�,��	�%�f�-��rc��d|jg|_|jr%|jj|j�|jr%|jj|j�|j
�y)zUruns nosetests with the specified test suite, all plugins
        activated.
        �	nosetestsN)�activaterI�args�extendrR�appendrWrs r�setUpzPluginTester.setUpsZ��!�$�-�-�0��	��9�9��I�I���T�Y�Y�'��>�>��I�I���T�^�^�,����r)r7r8r9r:rZrRr[rGrIrFrQr>rWr^rrrrr�s<�� �B�H��I��D�
�C��D��G��K�"�(.�*
rc�,�eZdZdZdZd�Zd�Zd�Zd�Zy)rTNc��||_|jd�|j�|_|jd�yr)rHr.�read�_buf)rrHs  rrzAccessDecorator.__init__s,��������A���K�K�M��	����A�rc��||jvSr-�rb)r�vals  r�__contains__zAccessDecorator.__contains__s���d�i�i��rc�,�t|j�Sr-)�iterrHrs rr+zAccessDecorator.__iter__s���D�K�K� � rc��|jSr-rdrs r�__str__zAccessDecorator.__str__s���y�y�r)	r7r8r9rHrbrrfr+rjrrrrTrTs ��
�F��D��
 �!�rrTc#� K�g}|jd�D]^}|j|�|j�}|r$|jd�s�8|jd�r�Jdj	|���g}�`|rdj	|���yy�w)z9a bunch of === characters is also considered a blank lineTz===�=�N)�
splitlinesr]�strip�
startswith�join)�text�block�lines   r�blankline_separated_blocksru#sx�����E�����%��
���T���z�z�|���t���u�-�d�j�j��o��'�'�%�.� ��E�&�
��g�g�e�n��
�s�AB�B� .Bc��tjdtjtjztjz�}g}t|�D]#}|j
|jd|���%dj|�S)NaD
        # Grab the traceback header.  Different versions of Python have
        # said different things on the first traceback line.
        ^(?P<hdr> Traceback\ \(
            (?: most\ recent\ call\ last
            |   innermost\ last
            ) \) :
        )
        \s* $                   # toss trailing whitespace on the header.
        (?P<stack> .*?)         # don't blink: absorb stuff until...
        ^(?=\w)                 #     a line *starts* with alphanum.
        .*?(?P<exception> \w+ ) # exception name
        (?P<msg> [:\n] .*)      # the rest
        z"\g<hdr>\n...\n\g<exception>\g<msg>rm)	�re�compile�VERBOSE�	MULTILINE�DOTALLrur]�subrq)�out�traceback_re�blocksrss    r�remove_stack_tracesr�0sn���:�:�
��Z�Z�"�,�,�
&����
2�
4�L��F�+�C�0���
�
�l�&�&�'L�e�T�U�1�
�7�7�6�?�rc��tjdtjtjz�}|j	d|�S)Nz�
        # Cut the file and line no, up to the warning name
        ^.*:\d+:\s
        (?P<category>\w+): \s+        # warning category
        (?P<detail>.+) $ \n?          # warning message
        ^ .* $                        # stack frame
        z\g<category>: \g<detail>)rwrxryrzr|)r}�warn_res  r�simplify_warningsr�Fs;���j�j���Z�Z�"�,�,�
&�
(�G��;�;�2�C�8�8rc�0�tjdd|�S)NzRan (\d+ tests?) in [0-9.]+szRan \1 in ...s)rwr|�r}s r�remove_timingsr�Qs��
�6�6�'�):�C�A�Arc�d�t|�}t|�}t|�}|j�S)z6Modify nose output to make it easy to use in doctests.)r�r�r�ror�s r�munge_nose_output_for_doctestr�Vs,��
�c�
"�C�
�C�
 �C�
��
�C��9�9�;�rc��ddlm}ddlm}ddlm}t
�}d|vrJ|jdg�}t|t�r	||��}|jdi�}|||�	�|d<d
|vrddg|d
<||d_
tj}tj}	|jd
d�r|xt_
t_d}
nd}
tdtd��	||i|��|
r|t_|	t_
	|j!�}t#t%|��y#|
r|t_|	t_
wwxYw)a�
    Specialized version of nose.run for use inside of doctests that
    test test runs.

    This version of run() prints the result output to stdout.  Before
    printing, the output is processed by replacing the timing
    information with an ellipsis (...), removing traceback stacks, and
    removing trailing whitespace.

    Use this version of run wherever you are writing a doctest that
    tests nose (or unittest) test result output.

    Note: do not use doctest: +ELLIPSIS when testing nose output,
    since ellipses ("test_foo ... ok") in your expected test runner
    output may match multiple lines of output, causing spurious test
    passes!
    r�rr@rCrJrFrErG)rGrFrIrYz-v�
buffer_allFTaThe behavior of nose.plugins.plugintest.run() will change in the next release of nose. The current behavior does not correctly account for output to stdout and stderr. To enable correct behavior, use run_buffered() instead, or pass the keyword argument buffer_all=True to run().�)�
stacklevelN)rSrrMrArOrDrP�pop�
isinstance�listrH�sys�stderr�stdoutr�DeprecationWarningr2�printr�)�arg�kwrrArDr$rFrGr�r��restorer}s            rrr^s%��$�"�2�
�X�F��r���&�&��B�'���g�t�$�#�G�4�G��f�f�U�B����#�w�7��8��
�R��!�4�(��6�
� �B�x�L���Z�Z�F�
�Z�Z�F�	�v�v�l�E�"�"(�(��
�S�Z������>�
 �A�	/� ��S��B����C�J��C�J�
�/�/�
�C�	�
'��
,�-��	��C�J��C�J��s� D&�&Ec�$�d|d<t|i|��y)NTr�r�)r�r�s  r�run_bufferedr��s���B�|����O��Or�__main__)r:rwr��warningsr�ior�ImportError�__all__�osr�objectr	r'r
rPrrTrur�r�r�r�rr�r7�doctest�testmodrrr�<module>r�s���_�B
�
�����5�
!���=,�v�=,�~�'�
�F�]�6�]�@
�f�
� 
��,9�A�
�9.�x��z����G�O�O����m	�����P��
�F��s"�A=�B�=B�
B�B�B


Current_dir [ NOT WRITEABLE ] Document_root [ WRITEABLE ]


[ Back ]
NAME
SIZE
LAST TOUCH
USER
CAN-I?
FUNCTIONS
..
--
4 Apr 2025 8.03 AM
root / root
0755
__init__.cpython-312.pyc
6.404 KB
4 Apr 2025 8.03 AM
root / root
0644
allmodules.cpython-312.pyc
2.301 KB
4 Apr 2025 8.03 AM
root / root
0644
attrib.cpython-312.pyc
9.89 KB
4 Apr 2025 8.03 AM
root / root
0644
base.cpython-312.pyc
30.225 KB
4 Apr 2025 8.03 AM
root / root
0644
builtin.cpython-312.pyc
1.157 KB
4 Apr 2025 8.03 AM
root / root
0644
capture.cpython-312.pyc
5.098 KB
4 Apr 2025 8.03 AM
root / root
0644
collect.cpython-312.pyc
4.975 KB
4 Apr 2025 8.03 AM
root / root
0644
cover.cpython-312.pyc
13.917 KB
4 Apr 2025 8.03 AM
root / root
0644
debug.cpython-312.pyc
3.077 KB
4 Apr 2025 8.03 AM
root / root
0644
deprecated.cpython-312.pyc
2.106 KB
4 Apr 2025 8.03 AM
root / root
0644
doctests.cpython-312.pyc
21.004 KB
4 Apr 2025 8.03 AM
root / root
0644
errorclass.cpython-312.pyc
9.29 KB
4 Apr 2025 8.03 AM
root / root
0644
failuredetail.cpython-312.pyc
2.273 KB
4 Apr 2025 8.03 AM
root / root
0644
isolate.cpython-312.pyc
5.177 KB
4 Apr 2025 8.03 AM
root / root
0644
logcapture.cpython-312.pyc
12.53 KB
4 Apr 2025 8.03 AM
root / root
0644
manager.cpython-312.pyc
21.718 KB
4 Apr 2025 8.03 AM
root / root
0644
multiprocess.cpython-312.pyc
38.254 KB
4 Apr 2025 8.03 AM
root / root
0644
plugintest.cpython-312.pyc
17.021 KB
4 Apr 2025 8.03 AM
root / root
0644
prof.cpython-312.pyc
6.642 KB
4 Apr 2025 8.03 AM
root / root
0644
skip.cpython-312.pyc
2.459 KB
4 Apr 2025 8.03 AM
root / root
0644
testid.cpython-312.pyc
11.73 KB
4 Apr 2025 8.03 AM
root / root
0644
xunit.cpython-312.pyc
16.276 KB
4 Apr 2025 8.03 AM
root / root
0644

GRAYBYTE WORDPRESS FILE MANAGER @ 2025 CONTACT ME
Static GIF