403Webshell
Server IP : 192.158.238.246  /  Your IP : 18.222.24.251
Web Server : LiteSpeed
System : Linux uniform.iwebfusion.net 4.18.0-553.27.1.lve.1.el8.x86_64 #1 SMP Wed Nov 20 15:58:00 UTC 2024 x86_64
User : jenniferflocom ( 1321)
PHP Version : 8.1.32
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /opt/alt/python37/lib/python3.7/site-packages/nose/plugins/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /opt/alt/python37/lib/python3.7/site-packages/nose/plugins/__pycache__/doctests.cpython-37.pyc
B

0�SeFD�	@s\dZddlZddlZddlZddlZddlmZddlmZddl	m
Z
ddlmZm
Z
mZmZmZmZmZyddlmZWn ek
r�ddlmZYnXddlZddlZe�e�ZyddlZejWn*eefk
r�ddlmm ZYnXej!Z"Gdd	�d	e"�Z#e#e_!Gd
d�dej$�Z%Gdd
�d
e�Z&Gdd�dej�ZGdd�dej'�Z'dS)a�Use the Doctest plugin with ``--with-doctest`` or the NOSE_WITH_DOCTEST
environment variable to enable collection and execution of :mod:`doctests
<doctest>`.  Because doctests are usually included in the tested package
(instead of being grouped into packages or modules of their own), nose only
looks for them in the non-test packages it discovers in the working directory.

Doctests may also be placed into files other than python modules, in which
case they can be collected and executed by using the ``--doctest-extension``
switch or NOSE_DOCTEST_EXTENSION environment variable to indicate which file
extension(s) to load.

When loading doctests from non-module files, use the ``--doctest-fixtures``
switch to specify how to find modules containing fixtures for the tests. A
module name will be produced by appending the value of that switch to the base
name of each doctest file loaded. For example, a doctest file "widgets.rst"
with the switch ``--doctest_fixtures=_fixt`` will load fixtures from the module
``widgets_fixt.py``.

A fixtures module may define any or all of the following functions:

* setup([module]) or setup_module([module])
   
  Called before the test runs. You may raise SkipTest to skip all tests.
  
* teardown([module]) or teardown_module([module])

  Called after the test runs, if setup/setup_module did not raise an
  unhandled exception.

* setup_test(test)

  Called before the test. NOTE: the argument passed is a
  doctest.DocTest instance, *not* a unittest.TestCase.
  
* teardown_test(test)
 
  Called after the test, if setup_test did not raise an exception. NOTE: the
  argument passed is a doctest.DocTest instance, *not* a unittest.TestCase.
  
Doctests are run like any other test, with the exception that output
capture does not work; doctest does its own output capture while running a
test.

.. note ::

   See :doc:`../doc_tests/test_doctest_fixtures/doctest_fixtures` for
   additional documentation and examples.

�N)�	getmodule)�Plugin)�ContextList)�anyp�
getpackage�test_address�resolve_name�src�tolist�
isproperty)�StringIOc@s$eZdZdd�Zdd�Zdd�ZdS)�NoseOutputRedirectingPdbcCsd|_t�||�dS)NF)�(_NoseOutputRedirectingPdb__debugger_used�_orp�__init__)�self�out�r�F/opt/alt/python37/lib/python3.7/site-packages/nose/plugins/doctests.pyrZsz!NoseOutputRedirectingPdb.__init__cCsd|_t�|t��j�dS)NT)rr�	set_trace�sys�	_getframe�f_back)rrrrr^sz"NoseOutputRedirectingPdb.set_tracecCs|jrt�|�dS)N)rr�set_continue)rrrrrbsz%NoseOutputRedirectingPdb.set_continueN)�__name__�
__module__�__qualname__rrrrrrrr
Ysr
c@s6eZdZdZdZd
dd�Zdd�Zd	d
�Zdd�ZdS)�DoctestSuitea�
    Doctest suites are parallelizable at the module or file level only,
    since they may be attached to objects that are not individually
    addressable (like properties). This suite subclass is used when
    loading doctests from a module to ensure that behavior.

    This class is used only if the plugin is not fully prepared;
    in normal use, the loader's suiteClass is used.
    
    FrNcCs ||_||_tjj||d�dS)N)�tests)�context�	can_split�unittest�	TestSuiter)rrrr rrrrwszDoctestSuite.__init__cCs
t|j�S)N)rr)rrrr�address|szDoctestSuite.addresscCs
t|j�S)N)�iter�_tests)rrrr�__iter__szDoctestSuite.__iter__cCs
t|j�S)N)�strr%)rrrr�__str__�szDoctestSuite.__str__)rNF)	rrr�__doc__r rr#r&r(rrrrrjs

rc@sXeZdZdZdZeZdd�Zdd�Zdd�Z	d	d
�Z
dd�Zd
d�Zdd�Z
dd�ZdS)�DoctestzO
    Activate doctest plugin to find and run doctests in non-test modules.
    NcCs�t�|||�|jddd|�d�dd�|jddd	d
dd�|jd
d|�d�ddd�|jdddddd�|jdddddd�|�d�}|dk	r�|jt|�d�dS)z'Register commmandline options.
        z--doctest-tests�
store_true�
doctest_testsZNOSE_DOCTEST_TESTSz�Also look for doctests in test modules. Note that classes, methods and functions should have either doctests or non-doctest tests, not both. [NOSE_DOCTEST_TESTS])�action�dest�default�helpz--doctest-extension�append�doctestExtensionZEXTzLAlso look for doctests in files with this extension [NOSE_DOCTEST_EXTENSION])r-r.�metavarr0z--doctest-result-variable�doctest_result_varZNOSE_DOCTEST_RESULT_VARZVARz�Change the variable name set to the result of the last interpreter command from the default '_'. Can be used to avoid conflicts with the _() function used for text translation. [NOSE_DOCTEST_RESULT_VAR])r.r/r3r0z--doctest-fixtures�store�doctestFixturesZSUFFIXzgFind fixtures for a doctest file in module with this name appended to the base name of the doctest filez--doctest-options�doctestOptionsZOPTIONSzISpecify options to pass to doctest. Eg. '+ELLIPSIS,+NORMALIZE_WHITESPACE'ZNOSE_DOCTEST_EXTENSIONN)r2)r�options�
add_option�get�set_defaultsr
)r�parser�envZenv_settingrrrr8�s2
zDoctest.optionscCs�t�|||�|j|_|j|_t|j�|_|j|_t	�
�|_d|_|j
r�d�|j
��d�}x�|D]�}|rt|ddkr�tdd|f��|d|dd�}}t	j�|�}|s�td|f��|d	kr�|j|O_q`|d
kr`|j|M_q`WdS)zConfigure plugin.
        r�,z+-z+Must specify doctest options with starting z'+' or '-'.  Got %s�NzUnknown doctest option %s�+�-)r�	configurer4r,r
r2�	extensionr6�fixtures�doctestZ
DocTestFinder�finder�optionflagsr7�join�split�
ValueErrorZOPTIONFLAGS_BY_NAMEr:)rr8�config�flags�flag�mode�option_nameZoption_flagrrrrB�s.


zDoctest.configurecCs|j|_dS)znCapture loader's suiteClass.

        This is used to create test suites from doctest files.
        
        N)�
suiteClass)r�loaderrrr�prepareTestLoader�szDoctest.prepareTestLoaderccs�t�d|�|�|j�s(t�d|�dSy|j�|�}Wn tk
rXt�d|�dSX|snt�d|�dS|��t	|j
�}g}x8|D]0}|js�q�|js�||_|�
t||j|jd��q�W|r�|j||dd�VdS)	z'Load doctests from the module.
        zloading from %szDoctest doesn't want module %sNzAttribute error loading from %szNo tests found in %s)rG�
result_varF)rr )�log�debug�matchesrrF�find�AttributeError�	exception�sortr	�__file__�examples�filenamer1�DocTestCaserGr4rP)r�moduler�module_file�cases�testrrr�loadTestsFromModule�s2

zDoctest.loadTestsFromModulec
csl|j�rht|j|j��rhtj�|�}t|�}z|��}Wd|��Xd}d|i}|j	r�tj�
|�\}}tj�|�}	tj�
|	�||j	}
yt|
t�t�dg�}Wn4tk
r�}zt�d|
|tj�Wdd}~XYnXt�d|
|�t|d�r�|�|�}t��}|j||||dd�}
|
j�rbt|
|jt|d	d�t|d
d�|jd�}|�rZt|f|d�Vn|Vnd
VdS)z�Load doctests from the file.

        Tests are loaded only if filename's extension matches
        configured doctest extension.

        Nr[ZnopzCould not import %s: %s (%s)z Fixture module %s resolved to %s�globsr)rd�namer]�linenoZ
setup_testZ
teardown_test)rG�setUp�tearDownrS)rF)rCr�endswith�os�path�basename�open�read�closerD�splitext�dirnamerr1�
__import__�globals�locals�ImportErrorrTrU�hasattrrdrEZ
DocTestParserZget_doctestr\�DocFileCaserG�getattrr4r)rr]reZdh�docZfixture_contextrd�base�extrqZfixt_mod�er<rb�caserrr�loadTestsFromFile�sL

 





zDoctest.loadTestsFromFileccsft|ddt|��}|jj|t|�|d�}|rbx2|D]*}t|j�dkrHq4t|||j|j	d�Vq4WdS)zbLook for doctests in the given object, which will be a
        function, method or class.
        rzUnnammed %s)r_rer)�objrGrSN)
rx�typerFrWr�lenr\r^rGr4)rr�parentre�doctestsrbrrr�makeTest/s

zDoctest.makeTestcsv�dkrdS|jsJ|jj���sJ|jjotdd��fdd�|jjD�D�ot|jjptdd��fdd�|jjD�D�S)Nz__init__.pyFcSsg|]}|r|�qSrr)�.0�_frrr�
<listcomp>Dsz#Doctest.matches.<locals>.<listcomp>csg|]}|����qSr)�search)r�Zinc)rerrr�DscSsg|]}|r|�qSrr)r�r�rrrr�Gscsg|]}|����qSr)r�)r��exc)rerrr�Gs)r,�confZ	testMatchr��include�exclude)rrer)rerrV<s
zDoctest.matchescsR��d�rdS|jrNt�j|j�rN|jjrJdd��fdd�|jjD�D�sNdSdS)zfOverride to select all modules and any file ending with
        configured doctest extension.
        z.pyTcSsg|]}|r|�qSrr)r�r�rrrr�Usz$Doctest.wantFile.<locals>.<listcomp>csg|]}|����qSr)r�)r�r�)�filerrr�UsN)rirCrr�r�)rr�r)r�r�wantFileJs
zDoctest.wantFile)rrrr)rCrrPr8rBrRrcr~r�rVr�rrrrr*�s+!2
r*csfeZdZdZd�fdd�	Zdd�Zd	d
�Zdd�ZeZd
d�Z	�fdd�Z
dd�Z�fdd�Z�Z
S)r^a#Overrides DocTestCase to
    provide an address() method that returns the correct address for
    the doctest case. To provide hints for address(), an obj may also
    be passed -- this will be used as the test object for purposes of
    determining the test address, if it is provided.
    rN�_cs*||_||_tt|�j|||||d�dS)N)rGrgrh�checker)�_result_var�	_nose_obj�superr^r)rrbrGrgrhr�rrS)�	__class__rrrbs

zDocTestCase.__init__cCs�|jdk	rt|j�St|jj�}t|�r||jj�d�}d�|dd��}t|�}t|�}|d|dd�|d|dg�fSt|�SdS)N�.���rr?�)r�rr�_dt_testrerrIrH)rr�parts�
class_name�clsZ	base_addrrrrr#js

zDocTestCase.addresscCsF|jj}|jj}|dk	rBt|�}|dkr,|S|�|�sBd||f}|S)Nz%s.%s)r�rer]r�
startswith)rrer]�pkrrr�ids
zDocTestCase.idcCs0|��}|�d�}d|dd�|dd��fS)Nr�z%s (%s)r�)r�rIrH)rrerrr�__repr__�s
zDocTestCase.__repr__cCsd|��S)NzDoctest: %s)r�)rrrr�shortDescription�szDocTestCase.shortDescriptioncs,|jdk	rtj|_|jt_tt|���dS)N)r�r�displayhook�_old_displayhook�_displayhookr�r^rg)r)r�rrrg�s
zDocTestCase.setUpcCs*|dkrdStt|j|�tt|��dS)N)�setattr�builtin_modr��print�repr)r�valuerrrr��szDocTestCase._displayhookcs0tt|���|jdk	r,|jt_tt|j�dS)N)	r�r^rhr�r�rr��delattrr�)r)r�rrrh�s
zDocTestCase.tearDown)rNNNNr�)rrrr)rr#r�r�r(r�rgr�rh�
__classcell__rr)r�rr^[sr^csJeZdZdZd�fdd�	Zdd�Z�fd	d
�Zdd�Z�fd
d�Z�Z	S)rwzfOverrides to provide address() method that returns the correct
    address for the doc file case.
    rNr�cs$||_tt|�j||||dd�dS)N)rGrgrhr�)r�r�rwr)rrbrGrgrhr�rS)r�rrr�s
zDocFileCase.__init__cCs|jjddfS)N)r�r])rrrrr#�szDocFileCase.addresscs,|jdk	rtj|_|jt_tt|���dS)N)r�rr�r�r�r�rwrg)r)r�rrrg�s
zDocFileCase.setUpcCs*|dkrdStt|j|�tt|��dS)N)r�r�r�r�r�)rr�rrrr��szDocFileCase._displayhookcs0tt|���|jdk	r,|jt_tt|j�dS)N)	r�rwrhr�r�rr�r�r�)r)r�rrrh�s
zDocFileCase.tearDown)rNNNr�)
rrrr)rr#rgr�rhr�rr)r�rrw�srw)(r)�loggingrjrr!�inspectrZnose.plugins.baserZ
nose.suiterZ	nose.utilrrrrr	r
r�iorru�builtinsr��	getLoggerrrTrEr^rXZnose.ext.dtcompatr{ZdtcompatZ_OutputRedirectingPdbrr
r"rr*rwrrrr�<module>1s8$

UK

Youez - 2016 - github.com/yon3zu
LinuXploit