403Webshell
Server IP : 192.158.238.246  /  Your IP : 3.15.7.155
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/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

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

.�Se��@sfdZddlZddlmZmZddlmZmZddddd	gZda	d
d�Z
e
�\ZZdd	�Z
d
dd�ZdS)av
Twisted integration
-------------------

This module provides a very simple way to integrate your tests with the
Twisted_ event loop.

You must import this module *before* importing anything from Twisted itself!

Example::

  from nose.twistedtools import reactor, deferred
  
  @deferred()
  def test_resolve():
      return reactor.resolve("www.python.org")

Or, more realistically::

  @deferred(timeout=5.0)
  def test_resolve():
      d = reactor.resolve("www.python.org")
      def check_ip(ip):
          assert ip == "67.15.36.43"
      d.addCallback(check_ip)
      return d

.. _Twisted: http://twistedmatrix.com/trac/
�N)�Queue�Empty)�make_decorator�TimeExpired�threaded_reactor�reactor�deferredr�stop_reactorcsnyddlm�Wntk
r$dSXtsfddlm}ddlm}|�fdd�d�at�d	�t�	��tfS)
z�
    Start the Twisted reactor in a separate thread, if not already done.
    Returns the reactor.
    The thread will automatically be destroyed when all the tests are done.
    r)r)NN)�
threadable)�Threadcs�jdd�S)NF)ZinstallSignalHandlers)�run�)rr
�B/opt/alt/python37/lib/python3.7/site-packages/nose/twistedtools.py�<lambda>8sz"threaded_reactor.<locals>.<lambda>)�targetT)
Ztwisted.internetr�ImportError�_twisted_threadZtwisted.pythonr
�	threadingr�	setDaemon�start)r
rr
)rrr*s
cCsDdd�}t�|�t��x t��D]}|��r$|��q$WdadS)aStop the reactor and join the reactor thread until it stops.
    Call this function in teardown at the module or package level to
    reset the twisted system after your tests. You *must* do this if
    you mix tests using these tools and tests using twisted.trial.
    cSst��dS)z0Helper for calling stop from withing the thread.N)r�stopr
r
r
rr	Jsz"stop_reactor.<locals>.stop_reactorN)r�callFromThread�reactor_thread�joinZgetDelayedCallsZactive�cancelr)r	�pr
r
rr	Bs
cs^t�\�}�dkrtd��y�dkp*�dWntk
rJtd��YnX��fdd�}|S)a
    By wrapping a test function with this decorator, you can return a
    twisted Deferred and the test will wait for the deferred to be triggered.
    The whole test function will run inside the Twisted event loop.

    The optional timeout parameter specifies the maximum duration of the test.
    The difference with timed() is that timed() will still wait for the test
    to end, while deferred() will stop the test when its timeout has expired.
    The latter is more desireable when dealing with network tests, because
    the result may actually never arrive.

    If the callback is triggered, the test has passed.
    If the errback is triggered or the timeout expires, the test has failed.

    Example::
    
        @deferred(timeout=5.0)
        def test_resolve():
            return reactor.resolve("www.python.org")

    Attention! If you combine this decorator with other decorators (like
    "raises"), deferred() must be called *first*!

    In other words, this is good::
        
        @raises(DNSLookupError)
        @deferred()
        def test_error():
            return reactor.resolve("xxxjhjhj.biz")

    and this is bad::
        
        @deferred()
        @raises(DNSLookupError)
        def test_error():
            return reactor.resolve("xxxjhjhj.biz")
    Nz1twisted is not available or could not be importedrz+'timeout' argument must be a number or Nonecs ���fdd�}t��|�}|S)Ncs�t���fdd���fdd��������fdd�}��|�y�j�d�}Wn tk
rntd���YnX|dk	r�|\}}}||��|��dS)	Ncs��d�dS)N)�put)�value)�qr
r�callback�sz=deferred.<locals>.decorate.<locals>.wrapper.<locals>.callbackcs,y|��Wn��t���YnXdS)N)ZraiseExceptionr�sys�exc_info)Zfailure)rr
r�errback�sz<deferred.<locals>.decorate.<locals>.wrapper.<locals>.errbackcs\y<����}y|����Wntk
r8td��YnXWn��t���YnXdS)Nz7you must return a twisted Deferred from your test case!)ZaddCallbacks�AttributeError�	TypeErrorrr r!)�d)�argsrr"�func�kargsrr
r�g�s
z6deferred.<locals>.decorate.<locals>.wrapper.<locals>.g)�timeoutz*timeout expired before end of test (%f s.))rr�getrr�with_traceback)r&r(r)�error�exc_type�	exc_value�tb)r'rr*)r&rr"r(rr�wrapper�s

z+deferred.<locals>.decorate.<locals>.wrapper)r)r'r1)rr*)r'r�decorate�s"zdeferred.<locals>.decorate)rrr$)r*rr2r
)rr*rrVs&
%)N)�__doc__r �queuerrZ
nose.toolsrr�__all__rrrrr	rr
r
r
r�<module>s


Youez - 2016 - github.com/yon3zu
LinuXploit