File: //lib/python3/dist-packages/hamcrest/library/number/__pycache__/iscloseto.cpython-38.pyc
U
�b�V� � @ sP d dl Z d dlmZ d dlmZ dZdZdZdd� ZG d d
� d
e�Z dd� Z
dS )
� N)�BaseMatcher)�fabszJon ReidzCopyright 2011 hamcrest.orgzBSD, see License.txtc C sZ t | ttftj �rdS zt| �d d d }W dS tk
rH Y dS Y dS X dS )zKConfirm that 'value' can be treated numerically; duck-test accordingly
Tr � F)�
isinstance�float�complex�sixZ
integer_typesr �ArithmeticError)�value�_� r �C/usr/lib/python3/dist-packages/hamcrest/library/number/iscloseto.py� isnumeric
s r c s4 e Zd Zdd� Zdd� Z� fdd�Zdd� Z� ZS ) � IsCloseToc C s0 t |�std��t |�s td��|| _|| _d S )NzIsCloseTo value must be numericzIsCloseTo delta must be numeric)r � TypeErrorr
�delta)�selfr
r r r r
�__init__ s zIsCloseTo.__init__c C s t |�sdS t|| j �| jkS )NF)r r r
r )r �itemr r r
�_matches% s zIsCloseTo._matchesc sD t |�stt| ��||� n$t|| j �}|�|��d��|� d S )Nz
differed by )r �superr �describe_mismatchr r
�append_description_of�append_text)r r Zmismatch_descriptionZactual_delta�� __class__r r
r * s
��zIsCloseTo.describe_mismatchc C s$ |� d��| j�� d��| j� d S )Nza numeric value within z of )r r r r
)r Zdescriptionr r r
�describe_to3 s
���zIsCloseTo.describe_to)�__name__�
__module__�__qualname__r r r r �
__classcell__r r r r
r s r c C s
t | |�S )a� Matches if object is a number close to a given value, within a given
delta.
:param value: The value to compare against as the expected value.
:param delta: The maximum delta between the values for which the numbers
are considered close.
This matcher compares the evaluated object against ``value`` to see if the
difference is within a positive ``delta``.
Example::
close_to(3.0, 0.25)
)r )r
r r r r
�close_to: s r! )r Zhamcrest.core.base_matcherr Zmathr �
__author__Z
__copyright__Z__license__r r r! r r r r
�<module> s