
    Vhv                     Z    d Z ddlZddlmZ ddlmZmZ ddlmZ ddl	m
Z
  G d de
      Zy)	z6
Test that twisted scripts can be invoked as modules.
    N)StringIO)deferreactor)Accumulator)TestCasec                   "    e Zd ZdZd Zd Zd Zy)	MainTestsz4Test that twisted scripts can be invoked as modules.c                 ^    t         j                  }t               t        j                         x}_        t        j                  ||dddgd       j                  j                          ddl
m}  j                  t         d|j                  dg        fd	}|j                  |      S )
z0Invoking python -m twisted should execute twist.-mtwisted--helpNenvr   __main__argvc                 f    j                   }|j                         }j                  d|v |       y )Ns,   -m twisted [options] plugin [plugin_options]outFgetvalue
assertTrueignfoutputpselfs      F/home/dcms/DCMS/lib/python3.12/site-packages/twisted/test/test_main.pyprocessEndedz,MainTests.test_twisted.<locals>.processEnded!   s-    AZZ\FOO?6I6    )sys
executabler   r   DeferredendedDeferredr   spawnProcess	transport
closeStdinr   r   patch__file__addCallbackr   cmddr   r   r   s   `    @r   test_twistedzMainTests.test_twisted   s    nnM#nn..AOQc4H%E4P	  	%

3!2!2H =>	 }}\**r    c                 ^    t         j                  }t               t        j                         x}_        t        j                  ||dddgd       j                  j                          ddl
m}  j                  t         d|j                  dg        fd	}|j                  |      S )
z6Invoking python -m twisted.trial should execute trial.r   ztwisted.trialr   Nr   r   r   r   c                 f    j                   }|j                         }j                  d|v |       y )Ns   -j, --jobs= r   r   s      r   r   z*MainTests.test_trial.<locals>.processEnded8   s*    AZZ\FOOOv5v>r    )r!   r"   r   r   r#   r$   r   r%   r&   r'   twisted.trialr   r(   r)   r*   r+   s   `    @r   
test_trialzMainTests.test_trial+   s    nnM#nn..AOQc4(%KQUV	  	+

3!2!2H =>	? }}\**r    c                     t               }| j                  t        d|      }ddl}| j	                  |j
                         |j                          | j                  |j                         d       y)z2Importing twisted.__main__ does not execute twist.stdoutr   N )	r   r(   r!   twisted.__main__r   r   restoreassertEqualr   )r   r   monkeyr   s       r   test_twisted_importzMainTests.test_twisted_import@   sQ    C62(()*B/r    N)__name__
__module____qualname____doc__r.   r2   r:    r    r   r	   r	      s    >+.+*
0r    r	   )r>   r!   ior   twisted.internetr   r   twisted.test.test_processr   twisted.trial.unittestr   r	   r?   r    r   <module>rD      s'   
   + 1 +90 90r    