
    i                    ,   S r SSKJr  SSKrSSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SS	K	J
r
  \
(       a  SS
KJr  \R                  " SS9 " S S5      5       r\R                  " SS9 " S S5      5       r\R                   " S S5      5       r/ SQrg)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                      \ rS rSr% Sr\R                  " S SS9rS\S'   \R                  " S SS9r	S\S	'   SS
 jr
SS jrSrg)Instant   z
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                     [        5       $ Nr	        M/var/www/html/ai-image-ml/venv/lib/python3.13/site-packages/_pytest/timing.py<lambda>Instant.<lambda>#   s    DFr   F)default_factoryinitfloatr
   c                     [        5       $ r   r   r   r   r   r   r   (   s    r   
perf_countc                &    [        U [        5       S9$ )z1Measure the duration since `Instant` was created.)startstop)Durationr   selfs    r   elapsedInstant.elapsed+   s    d33r   c                `    [         R                  " U R                  [        R                  5      $ )zInstant as UTC datetime.)r   fromtimestampr
   r   utcr!   s    r   as_utcInstant.as_utc/   s    %%dii>>r   r   N)returnr    )r*   r   )__name__
__module____qualname____firstlineno____doc__dataclassesfieldr
   __annotations__r   r#   r(   __static_attributes__r   r   r   r   r      sH     ##NOD%O $)).UJ 4?r   r   c                  B    \ rS rSr% SrS\S'   S\S'   \S	S j5       rSrg)
r    4   z2A span of time as measured by `Instant.elapsed()`.r   r   r   c                \    U R                   R                  U R                  R                  -
  $ )zaElapsed time of the duration in seconds, measured using a performance counter for precise timing.)r   r   r   r!   s    r   secondsDuration.seconds;   s#     yy##djj&;&;;;r   r   Nr*   r   )	r+   r,   r-   r.   r/   r2   propertyr7   r3   r   r   r   r    r    4   s!    <N
M< <r   r    c                  x    \ rS rSr% Sr\" SSSSSS5      R                  5       rS	\S
'   SS jr	SS jr
SS jrSrg)
MockTimingA   a  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_timec                .    U =R                   U-  sl         g r   rC   )r"   r7   s     r   r   MockTiming.sleepP   s    g%r   c                    U R                   $ r   rE   r!   s    r   r
   MockTiming.timeS   s    !!!r   c                    SSK Jn  UR                  USU R                  5        UR                  USU R                  5        UR                  USU R                  5        g )Nr   )timingr   r
   r   )_pytestrJ   setattrr   r
   )r"   monkeypatchrJ   s      r   patchMockTiming.patchV   sG    "FGTZZ8FFDII6FNDII>r   r   N)r7   r   r*   Noner9   )rM   r   r*   rP   )r+   r,   r-   r.   r/   r   	timestamprC   r2   r   r
   rN   r3   r   r   r   r<   r<   A   s;    	_ $D!RR<FFHM5H&"?r   r<   )r   r   r
   )r/   
__future__r   r0   r   r   r
   r   r   typingr   pytestr   	dataclassr   r    r<   __all__r   r   r   <module>rW      s    #         " d#? ? $?6 d#	< 	< $	< ? ? ?8 ,r   