File: //usr/local/lib/python3.10/test/__pycache__/test_urllib2net.cpython-310.opt-1.pyc
o
�iD8 � @ sL d dl Z d dlZd dlmZ d dlmZ d dlmZ d dlmZ d dlm Z d dl
Z
d dlZd dlZ
d dlZ
d dlZe�d� dd � Zd
d� Ze�de
jv d
�Zee
jje
jj�ZG dd� de�Zeee jd�Zeee j d�Z!eee j d�Z"G dd� dej#�Z$G dd� dej#�Z%G dd� dej#�Z&G dd� dej#�Z'e(dkr�e�)� dS dS )� N)�support)� os_helper)�
socket_helper)�ResourceDenied)�sanepathname2urlZnetworkc O sN t d�D ] }z
| |i |��W S |y$ } z|}W Y d }~qd }~ww |�)N� )�range)�func�exc�args�kwargs�i�e�last_exc� r �1/usr/local/lib/python3.10/test/test_urllib2net.py�
_retry_thrice s ��r c s � �fdd�}|S )Nc s t �� g| �R i |��S �N)r )r r �r
r r r �wrapped s z(_wrap_with_retry_thrice.<locals>.wrappedr )r r
r r r r �_wrap_with_retry_thrice s r ZTRAVISz%bpo-35411: skip FTP test on Travis CIc @ s* e Zd ZdZdd� Zdd� Zd dd�ZdS )
�TransientResourcez�Raise ResourceDenied if an exception is raised while the context manager
is in effect that matches the specified exception and attributes.c K s || _ || _d S r )r
�attrs)�selfr
r r r r �__init__2 s
zTransientResource.__init__c C s | S r r �r r r r � __enter__6 � zTransientResource.__enter__Nc C s\ |dur*t | j|�r,| j�� D ]\}}t||�s dS t||�|kr% dS qtd��dS dS )z�If type_ is a subclass of self.exc and value has attributes matching
self.attrs, raise ResourceDenied. Otherwise let the exception
propagate (if any).Nz%an optional resource is not available)�
issubclassr
r �items�hasattr�getattrr )r Ztype_�value� traceback�attrZ
attr_valuer r r �__exit__9 s
��zTransientResource.__exit__)NNN)�__name__�
__module__�__qualname__�__doc__r r r% r r r r r - s
r )�errnoc @ s e Zd ZdZdS )� AuthTestsz&Tests urllib2 authentication features.N)r&