File: //lib/python3/dist-packages/twisted/python/test/__pycache__/test_urlpath.cpython-38.pyc
U
W[X( � @ sx d Z ddlmZ ddlmZ ddlmZ G dd� de�ZG dd� deej �Z
G d d
� d
eej �ZG dd� deej �Zd
S )z&
Tests for L{twisted.python.urlpath}.
� )�unittest)�urlpath)�_PY3c @ sx e Zd ZdZdd� Zdd� Zed�fdd�Zd d
� Zdd� Z d
d� Z
dd� Zdd� Zdd� Z
dd� Zdd� Zdd� ZdS )�_BaseURLPathTestsz5
Tests for instantiated L{urlpath.URLPath}s.
c C sT | � | jjt� | � | jjt� | � | jjt� | � | jjt� | � | jjt� dS )zQ
All of the attributes of L{urlpath.URLPath} should be L{bytes}.
N�ZassertIsInstance�path�scheme�bytes�netloc�query�fragment��self� r �B/usr/lib/python3/dist-packages/twisted/python/test/test_urlpath.py�test_partsAreBytes s
z$_BaseURLPathTests.test_partsAreBytesc C s | � t| j�� �t� dS )zQ
Calling C{str()} with a L{URLPath} will always return a L{str}.
N)�assertEqual�typer �__str__�strr
r r r �test_strReturnsStr s z$_BaseURLPathTests.test_strReturnsStr� c C s� |d�| j _| �t| j �d� |d�| j _| �t| j �d� |d�| j _ | �t| j �d� |d�| j _| �t| j �d� |d �| j _| �t| j �d
� dS )aC
Setting attributes on L{urlpath.URLPath} should change the value
returned by L{str}.
@param stringType: a callable to parameterize this test for different
text types.
@type stringType: 1-argument callable taking L{unicode} and returning
L{str} or L{bytes}.
Zhttpsz0https://example.com/foo/bar?yes=no&no=yes#footerzanother.example.invalidz<https://another.example.invalid/foo/bar?yes=no&no=yes#footerz/helloz:https://another.example.invalid/hello?yes=no&no=yes#footerzalpha=omega&opposites=samezGhttps://another.example.invalid/hello?alpha=omega&opposites=same#footer�headerzGhttps://another.example.invalid/hello?alpha=omega&opposites=same#headerN)r r r r r
r r )r Z
stringTyper r r �test_mutabilityWithText$ s2
�����z)_BaseURLPathTests.test_mutabilityWithTextc C s | � dd� � dS )zC
Same as L{test_mutabilityWithText} but for bytes.
c S s
| � d�S )N�ascii)�encode)�xr r r �<lambda>J � z<_BaseURLPathTests.test_mutabilityWithBytes.<locals>.<lambda>N)r r
r r r �test_mutabilityWithBytesF s z*_BaseURLPathTests.test_mutabilityWithBytesc C sT | � | jjt� | � | jjt� | � | jjt� | � | jjt� | � | jjt� dS )z<
A created L{URLPath} has bytes attributes.
Nr r
r r r �test_allAttributesAreBytesM s
z,_BaseURLPathTests.test_allAttributesAreBytesc C s | � t| j�d� dS )zs
Calling C{str()} with a L{URLPath} will return the same URL that it was
constructed with.
�/http://example.com/foo/bar?yes=no&no=yes#footerN)r r r r
r r r �test_stringConversionX s �z'_BaseURLPathTests.test_stringConversionc C sV | � t| j�d��d� | � t| j�d��d��d� | � t| jjddd��d� dS ) z�
Calling C{str()} with a C{URLPath.child()} will return a URL which is
the child of the URL it was instantiated with.
s helloz http://example.com/foo/bar/hellor z!http://example.com/foo/bar/hello/T�Z keepQueryz.http://example.com/foo/bar/hello?yes=no&no=yesN)r r r �childr
r r r �test_childStringa s ���z"_BaseURLPathTests.test_childStringc C sV | � t| j�d��d� | � t| jjddd��d� | � t| j�d��d��d� dS ) z�
Calling C{str()} with a C{URLPath.sibling()} will return a URL which is
the sibling of the URL it was instantiated with.
� bazzhttp://example.com/foo/bazTr# z(http://example.com/foo/baz?yes=no&no=yesr zhttp://example.com/foo/bar/bazN)r r r Zsiblingr$ r
r r r �test_siblingStringn s ���z$_BaseURLPathTests.test_siblingStringc C s� | � t| j�� �d� | � t| jjdd��d� | � t| j�d��� �d� | � t| j�d��� �d� | � t| j�� �� �� �� �� �d� dS ) z�
Calling C{str()} with a C{URLPath.parent()} will return a URL which is
the parent of the URL it was instantiated with.
zhttp://example.com/Tr# z!http://example.com/?yes=no&no=yesr �http://example.com/foo/r&