File: //usr/lib/python3/dist-packages/twisted/web/test/__pycache__/test_tap.cpython-310.pyc
o
�bB. � @ s. d Z ddlZddlZddlmZ ddlmZmZ ddlm Z ddl
mZ ddlm
Z
ddlmZ dd lmZ dd
lmZ ddlmZ ddlmZ dd
lmZmZ ddlmZ ddlmZ ddlm Z m!Z! ddl"m#Z#m$Z$m%Z%m&Z& ddl'm(Z( ddl)m*Z* ddl+m,Z, e-� Z.G dd� de�Z/G dd� de�Z0dS )z
Tests for L{twisted.web.tap}.
� N)�skipIf)� endpoints�reactor)�IReactorUNIX)�FilePath)�
requireModule)�
ThreadPool)�
UsageError)�PBServerFactory)�TestCase)�demo)�ResourcePublisher�
UserDirectory)�PythonScript)�Site)�Data�File)�Options�_AddHeadersResource�makePersonalServerFactory�makeService)�DummyRequest)� CGIScript)�WSGIResourcec @ s
e Zd ZdZdd� Zdd� Zee�e � d�dd� �Z
d d
� Zdd� Zd
d� Z
dd� Zee�e � d�dd� �Zee�e � d�dd� �Zdd� Zdd� Zdd� Zdd� Zeed�dud�d d!� �Zeed�du d"�d#d$� �Zd%d&� Zd'd(� Zd)d*� Zd+d,� Zd-d.� ZdS )/�ServiceTestszD
Tests for the service creation APIs in L{twisted.web.tap}.
c C s: t | �� �}|�� t� }|�d|jg� |d }||fS )a�
Helper for the I{--path} tests which creates a directory and creates
an L{Options} object which uses that directory as its static
filesystem root.
@return: A two-tuple of a L{FilePath} referring to the directory and
the value associated with the C{'root'} key in the L{Options}
instance after parsing a I{--path} option.
�--path�root)r �mktemp�makedirsr �parseOptions�path)�selfr �optionsr � r# �;/usr/lib/python3/dist-packages/twisted/web/test/test_tap.py�_pathOption, s
zServiceTests._pathOptionc C s, | � � \}}| �|t� | �|j|j� dS )z�
The I{--path} option causes L{Options} to create a root resource
which serves responses from the specified path.
N)r% �assertIsInstancer �assertEqualr �r! r r r# r# r$ � test_path= s zServiceTests.test_pathz0The reactor does not support UNIX domain socketsc C s� t | �� �}|�� | �� }t� }|�dd| d|jg� t|�}|�� | �|j � | �
|jd jj
t� | �|jd jj
j|j� | �tj�|�� | �t�t�|�j�� dS )z�
The I{--path} option to L{makeService} causes it to return a service
which will listen on the server address given by the I{--port} option.
�--port�unix:r r N)r r r r r r r �startService�
addCleanup�stopServicer&