§
    s
Êj|  ã                  óB  — d Z ddlmZ ddlZddlmZ ddlmZ ddlmZ ddlmZ ddlmZ dd	l	m
Z
 e
rdd
lmZ  ej        d¬¦  «         G d„ d¦  «        ¦   «         Z ej        d¬¦  «         G d„ d¦  «        ¦   «         Zej         G d„ d¦  «        ¦   «         Zg d¢ZdS )zøIndirection for time functions.

We intentionally grab some "time" functions internally to avoid tests mocking "time" to affect
pytest runtime information (issue #185).

Fixture "mock_timing" also interacts with this module for pytest's own tests.
é    )ÚannotationsN)Údatetime)Útimezone©Úperf_counter)Úsleep©Útime)ÚTYPE_CHECKING)ÚMonkeyPatchT)Úfrozenc                  ó„   — e Zd ZU dZ ej        d„ d¬¦  «        Zded<    ej        d„ d¬¦  «        Zded<   dd„Z	dd„Z
dS )ÚInstantz«
    Represents an instant in time, used to both get the timestamp value and to measure
    the duration of a time span.

    Inspired by Rust's `std::time::Instant`.
    c                 ó   — t          ¦   «         S ©Nr	   © ó    ú>C:\Projects\Muse2API\.venv\Lib\site-packages\_pytest/timing.pyú<lambda>zInstant.<lambda>$   s
   € ½D¹F¼F€ r   F)Údefault_factoryÚinitÚfloatr
   c                 ó   — t          ¦   «         S r   r   r   r   r   r   zInstant.<lambda>)   s
   € ¥¡¤€ r   Ú
perf_countÚreturnÚDurationc                ó<   — t          | t          ¦   «         ¬¦  «        S )z1Measure the duration since `Instant` was created.)ÚstartÚstop)r   r   ©Úselfs    r   ÚelapsedzInstant.elapsed-   s   € å˜d­©¬Ð3Ñ3Ô3Ð3r   r   c                óJ   — t          j        | j        t          j        ¦  «        S )zInstant as UTC datetime.)r   Úfromtimestampr
   r   Úutcr    s    r   Úas_utczInstant.as_utc1   s   € åÔ% d¤iµ´Ñ>Ô>Ð>r   N)r   r   )r   r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__ÚdataclassesÚfieldr
   Ú__annotations__r   r"   r&   r   r   r   r   r      s§   € € € € € € ðð ð $�+Ô#°N°NÈÐOÑOÔO€DÐOÐOÐOÑOð *˜Ô)Ø.Ð.Øðñ ô €Jð ð ð ñ ð
4ð 4ð 4ð 4ð?ð ?ð ?ð ?ð ?ð ?r   r   c                  ó@   — e Zd ZU dZded<   ded<   ed	d„¦   «         ZdS )
r   z2A span of time as measured by `Instant.elapsed()`.r   r   r   r   r   c                ó4   — | j         j        | j        j        z
  S )zaElapsed time of the duration in seconds, measured using a performance counter for precise timing.)r   r   r   r    s    r   ÚsecondszDuration.seconds=   s   € ð ŒyÔ# d¤jÔ&;Ñ;Ð;r   N©r   r   )r'   r(   r)   r*   r-   Úpropertyr0   r   r   r   r   r   6   sL   € € € € € € à<Ð<à€N€N�NØ€M€M�Màð<ð <ð <ñ „Xð<ð <ð <r   r   c                  óz   — e Zd ZU dZ edddddd¦  «                             ¦   «         Zded	<   dd„Zdd„Z	dd„Z
dS )Ú
MockTiminga  Mocks _pytest.timing with a known object that can be used to control timing in tests
    deterministically.

    pytest itself should always use functions from `_pytest.timing` instead of `time` directly.

    This then allows us more control over time during testing, if testing code also
    uses `_pytest.timing` functions.

    Time is static, and only advances through `sleep` calls, thus tests might sleep over large
    numbers and obtain accurate time() calls at the end, making tests reliable and instant.iä  é   é   é   é   é2   r   Ú_current_timer0   r   ÚNonec                ó&   — | xj         |z  c_         d S r   ©r:   )r!   r0   s     r   r   zMockTiming.sleepR   s   € ØÐÔ˜gÑ%ÐÔÐÐr   c                ó   — | j         S r   r=   r    s    r   r
   zMockTiming.timeU   s   € ØÔ!Ð!r   Úmonkeypatchr   c                óº   — ddl m} |                     |d| j        ¦  «         |                     |d| j        ¦  «         |                     |d| j        ¦  «         d S )Nr   )Útimingr   r
   r   )Ú_pytestrA   Úsetattrr   r
   )r!   r?   rA   s      r   ÚpatchzMockTiming.patchX   sh   € à"Ð"Ð"Ð"Ð"Ð"à×Ò˜F G¨T¬ZÑ8Ô8Ð8Ø×Ò˜F F¨D¬IÑ6Ô6Ð6Ø×Ò˜F N°D´IÑ>Ô>Ð>Ð>Ð>r   N)r0   r   r   r;   r1   )r?   r   r   r;   )r'   r(   r)   r*   r   Ú	timestampr:   r-   r   r
   rD   r   r   r   r4   r4   C   s‘   € € € € € € ð	_ð 	_ð $˜8 D¨!¨R°°R¸Ñ<Ô<×FÒFÑHÔH€MÐHÐHÐHÑHð&ð &ð &ð &ð"ð "ð "ð "ð?ð ?ð ?ð ?ð ?ð ?r   r4   )r   r   r
   )r*   Ú
__future__r   r+   r   r   r
   r   r   Útypingr   Úpytestr   Ú	dataclassr   r   r4   Ú__all__r   r   r   ú<module>rK      sŠ  ððð ð #Ð "Ð "Ð "Ð "Ð "à Ð Ð Ð Ø Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð Ø Ð Ð Ð Ð Ð Ø  Ð  Ð  Ð  Ð  Ð  ð ð #Ø"Ð"Ð"Ð"Ð"Ð"ð €Ô˜dÐ#Ñ#Ô#ð?ð ?ð ?ð ?ð ?ñ ?ô ?ñ $Ô#ð?ð: €Ô˜dÐ#Ñ#Ô#ð	<ð 	<ð 	<ð 	<ð 	<ñ 	<ô 	<ñ $Ô#ð	<ð Ôð?ð ?ð ?ð ?ð ?ñ ?ô ?ñ Ôð?ð: ,Ð
+Ð
+€€€r   