← Back
Editing: test_resource.cpython-38.pyc
U W[ � @ s� d Z ddlmZ ddlmZ ddlmZmZmZm Z m Z mZmZ ddl mZ ddlmZ G dd� de�ZG d d � d e�ZG dd� de�ZG d d� de�ZG dd� de�ZG dd� de�ZG dd� de�ZdS )z$ Tests for L{twisted.web.resource}. � )�TestCase)�UnsupportedMethod)� NOT_FOUND� FORBIDDEN�Resource� ErrorPage� NoResource�ForbiddenResource�getChildForRequest)�Headers)�DummyRequestc @ sD e Zd ZdZeZeZeZ dd� Z dd� Zdd� Zdd � Z d d� ZdS ) �ErrorPageTestszJ Tests for L{ErrorPage}, L{NoResource}, and L{ForbiddenResource}. c C s( | � ddd�}| �|�dt� �|� dS )zj The C{getChild} method of L{ErrorPage} returns the L{ErrorPage} it is called on. �A ZfooZbars nameN)� errorPage�assertIdentical�getChild�object)�self�page� r �@/usr/lib/python3/dist-packages/twisted/web/test/test_resource.py� test_getChild s zErrorPageTests.test_getChildc C s` t dg�}d}|||||f }| �|�|�|�d�� | �|j|� | �|jtddgi�� d S )N� zg <html> <head><title>%s - %s</title></head> <body> <h1>%s</h1> <p>%s</p> </body> </html> zutf-8s content-types text/html; charset=utf-8)r �assertEqual�render�encodeZresponseCodeZresponseHeadersr )r r �code�brief�detail�request�template�expectedr r r �_pageRenderingTest$ s � ��z!ErrorPageTests._pageRenderingTestc C s. d}d}d}| � |||�}| �||||� dS )a L{ErrorPage.render} returns a C{bytes} describing the error defined by the response code and message passed to L{ErrorPage.__init__}. It also uses that response code to set the response code on the L{Request} passed in. r zbrief description textzmuch longer text might go hereN)r r"