
    F-Ph                    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 )zIndirection 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	        N/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/_pytest/timing.py<lambda>zInstant.<lambda>#   s
    DFF 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_utc/   s    %di>>>r   N)r   r   )r   r   )__name__
__module____qualname____doc__dataclassesfieldr
   __annotations__r   r"   r&   r   r   r   r   r      s           $+#NNOOODOOOO *)..U  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#dj&;;;r   Nr   r   )r'   r(   r)   r*   r-   propertyr0   r   r   r   r   r   4   sL         <<NNNMMM< < < 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.sleepP   s    g%r   c                    | j         S r   r=   r    s    r   r
   zMockTiming.timeS   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.patchV   sh    """"""FGTZ888FFDI666FNDI>>>>>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   A   s         	_ 	_ $8D!RR<<FFHHM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###? ? ? ? ? ? ? $#?6 d###	< 	< 	< 	< 	< 	< 	< $#	< ? ? ? ? ? ? ? ?8 ,
+
+r   