File: //usr/lib/python3/dist-packages/twisted/names/test/__pycache__/test_hosts.cpython-38.pyc
U
W[c! � @ s� d Z ddlmZmZ ddlmZ ddlmZ ddlm Z ddl
mZmZm
Z
mZmZmZmZmZ ddlmZmZmZ G dd � d e�ZG d
d� dee�ZG dd
� d
ee�ZG dd� dee�ZdS )zC
Tests for the I{hosts(5)}-based resolver, L{twisted.names.hosts}.
� )�division�absolute_import)�TestCase)�FilePath��
gatherResults)�A�AAAA�IN�DomainError�RRHeader�Query�Record_A�Record_AAAA)�Resolver�
searchFileFor�searchFileForAllc @ s e Zd Zdd� ZdS )�GoodTempPathMixinc C s t | �� �d��S )Nzutf-8)r Zmktemp�encode��self� r �?/usr/lib/python3/dist-packages/twisted/names/test/test_hosts.py�path s zGoodTempPathMixin.pathN)�__name__�
__module__�__qualname__r r r r r r s r c @ s0 e Zd ZdZdd� Zdd� Zdd� Zdd � Zd
S )�SearchHostsFileTestsz�
Tests for L{searchFileFor}, a helper which finds the first address for a
particular hostname in a I{hosts(5)}-style file.
c C s* | � � }|�d� | �dt|j d�� dS )zr
If there is an IPv4 address for the hostname passed to L{searchFileFor},
it is returned.
� 10.2.3.4 foo.example.com
z10.2.3.4� foo.example.comN�r �
setContent�assertEqualr �r Zhostsr r r �test_findAddress s �
�z%SearchHostsFileTests.test_findAddressc C s( | � � }|�d� | �t|j d�� dS )z~
If there is no address information for the hostname passed to
L{searchFileFor}, L{None} is returned.
r s bar.example.comN)r r! ZassertIsNoner r# r r r �test_notFoundAddress* s
�z)SearchHostsFileTests.test_notFoundAddressc C s* | � � }|�d� | �dt|j d�� dS )zS
The first address associated with the given hostname is returned.
sV ::1 foo.example.com
10.1.2.3 foo.example.com
fe80::21b:fcff:feee:5a1d foo.example.com
�::1r Nr r# r r r �test_firstAddress5 s
�z&SearchHostsFileTests.test_firstAddressc C sz | � � }|�d� | �t|j d�d� | �t|j d�d� | �t|j d�d� | �t|j d�d� | �t|j d�d� d S )
z�
For a host with a canonical name and one or more aliases,
L{searchFileFor} can find an address given any of the names.
sY 127.0.1.1 helmut.example.org helmut
# a comment
::1 localhost ip6-localhost ip6-loopback
s helmutz 127.0.1.1s helmut.example.orgs
ip6-localhostr&