%PDF- %PDF-
Direktori : /usr/lib/python3/dist-packages/twisted/web/test/__pycache__/ |
Current File : //usr/lib/python3/dist-packages/twisted/web/test/__pycache__/test_pages.cpython-312.pyc |
� Ϫ�f@ � � � d Z ddlmZ ddlmZ ddlmZ ddlmZ ddl m Z mZmZ ddl mZ ddlmZ d ed efd�Z G d� d e� Zy)z Test L{twisted.web.pages} � )�cast)�SynchronousTestCase)�Headers)�IRequest)� errorPage� forbidden�notFound)� IResource)�DummyRequest�resource�returnc �\ � t dg� }| j t t |� � |S )z� Render a response using the given resource. @param resource: The resource to use to handle the request. @returns: The request that the resource handled, � )r �renderr r )r �requests �=/usr/lib/python3/dist-packages/twisted/web/test/test_pages.py�_renderr s* � � �C�5�!�G� �O�O�D��7�+�,��Nr c �L � e Zd ZdZdZdedededdfd�Zdd�Z dd �Z dd �Zdd�Zy) �ErrorPageTestszu Test L{twisted.web.pages._ErrorPage} and its public aliases L{errorPage}, L{notFound} and L{forbidden}. Nr �code�bodyr c � � | j |j |� | j |j t ddgi� � | j dj |j � j d� |j d� � y )Ns content-types text/html; charset=utf-8r zlatin-1)�assertEqual�responseCode�responseHeadersr �join�written�decode)�selfr r r s r �assertResponsezErrorPageTests.assertResponse* sy � �����-�-�t�4�����#�#��_�'B�&C�D�E� � ��� �H�H�W�_�_�%�,�,�Y�7��K�K� �"� r c �R � | j t t ddd� � dd� y)zS The I{brief} and I{detail} parameters are HTML-escaped on render. i� zA & Bz<script>alert('oops!')s� <!DOCTYPE html> <html><head><title>400 - A & B</title></head><body><h1>A & B</h1><p><script>alert('oops!')</p></body></html>N)r r r �r s r �test_escapesHTMLzErrorPageTests.test_escapesHTML7 s, � � ����I�c�7�,D�E�F��&� r c � � t ddd� }| j |j dt t t dg� � � |� y)z� The C{getChild} method of the resource returned by L{errorPage} returns the L{_ErrorPage} it is called on. � �foo�bars namer N)r �assertIs�getChildr r r )r �pages r � test_getChildzErrorPageTests.test_getChildF s= � � ��e�U�+��� � ��M�M�'�4��,��u�2E�#F�G�� r c �L � | j t t � � dd� y)zq The default arguments to L{twisted.web.pages.notFound} produce a reasonable error page. r% s� <!DOCTYPE html> <html><head><title>404 - No Such Resource</title></head><body><h1>No Such Resource</h1><p>Sorry. No luck finding that resource.</p></body></html>N)r r r r"