/
usr
/
lib
/
imh-scan
/
venv
/
lib
/
python3.13
/
site-packages
/
_pytest
/
/usr/lib/imh-scan/venv/lib/python3.13/site-packages/_pytest
mkdir
upload
Name
Size
Mode
Actions
assertion/
-
0755
rm
config/
-
0755
rm
mark/
-
0755
rm
_code/
-
0755
rm
_io/
-
0755
rm
_py/
-
0755
rm
__pycache__/
-
0755
rm
cacheprovider.py
22375
0644
edit
dl
rm
capture.py
36829
0644
edit
dl
rm
compat.py
10662
0644
edit
dl
rm
debugging.py
13947
0644
edit
dl
rm
deprecated.py
3147
0644
edit
dl
rm
doctest.py
26259
0644
edit
dl
rm
faulthandler.py
3683
0644
edit
dl
rm
fixtures.py
77746
0644
edit
dl
rm
freeze_support.py
1300
0644
edit
dl
rm
helpconfig.py
9386
0644
edit
dl
rm
hookspec.py
42849
0644
edit
dl
rm
junitxml.py
25441
0644
edit
dl
rm
legacypath.py
16588
0644
edit
dl
rm
logging.py
35234
0644
edit
dl
rm
main.py
37689
0644
edit
dl
rm
monkeypatch.py
14625
0644
edit
dl
rm
nodes.py
26540
0644
edit
dl
rm
outcomes.py
10502
0644
edit
dl
rm
pastebin.py
4155
0644
edit
dl
rm
pathlib.py
37622
0644
edit
dl
rm
py.typed
0
0644
edit
dl
rm
pytester.py
61960
0644
edit
dl
rm
pytester_assertions.py
2253
0644
edit
dl
rm
python.py
66627
0644
edit
dl
rm
python_api.py
31323
0644
edit
dl
rm
raises.py
60196
0644
edit
dl
rm
recwarn.py
13245
0644
edit
dl
rm
reports.py
21406
0644
edit
dl
rm
runner.py
19543
0644
edit
dl
rm
scope.py
2738
0644
edit
dl
rm
setuponly.py
3167
0644
edit
dl
rm
setupplan.py
1184
0644
edit
dl
rm
skipping.py
10623
0644
edit
dl
rm
stash.py
3090
0644
edit
dl
rm
stepwise.py
7689
0644
edit
dl
rm
terminal.py
60419
0644
edit
dl
rm
threadexception.py
4953
0644
edit
dl
rm
timing.py
3065
0644
edit
dl
rm
tmpdir.py
11263
0644
edit
dl
rm
tracemalloc.py
778
0644
edit
dl
rm
unittest.py
19249
0644
edit
dl
rm
unraisableexception.py
5179
0644
edit
dl
rm
warnings.py
5237
0644
edit
dl
rm
warning_types.py
4239
0644
edit
dl
rm
_argcomplete.py
3776
0644
edit
dl
rm
_version.py
704
0644
edit
dl
rm
__init__.py
391
0644
edit
dl
rm
Edit:
/usr/lib/imh-scan/venv/lib/python3.13/site-packages/_pytest/timing.py
(3065B)
"""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. """ from __future__ import annotations import dataclasses from datetime import datetime from datetime import timezone from time import perf_counter from time import sleep from time import time from typing import TYPE_CHECKING if TYPE_CHECKING: from pytest import MonkeyPatch @dataclasses.dataclass(frozen=True) class Instant: """ 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`. """ # Creation time of this instant, using time.time(), to measure actual time. # Note: using a `lambda` to correctly get the mocked time via `MockTiming`. time: float = dataclasses.field(default_factory=lambda: time(), init=False) # Performance counter tick of the instant, used to measure precise elapsed time. # Note: using a `lambda` to correctly get the mocked time via `MockTiming`. perf_count: float = dataclasses.field( default_factory=lambda: perf_counter(), init=False ) def elapsed(self) -> Duration: """Measure the duration since `Instant` was created.""" return Duration(start=self, stop=Instant()) def as_utc(self) -> datetime: """Instant as UTC datetime.""" return datetime.fromtimestamp(self.time, timezone.utc) @dataclasses.dataclass(frozen=True) class Duration: """A span of time as measured by `Instant.elapsed()`.""" start: Instant stop: Instant @property def seconds(self) -> float: """Elapsed time of the duration in seconds, measured using a performance counter for precise timing.""" return self.stop.perf_count - self.start.perf_count @dataclasses.dataclass class MockTiming: """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.""" _current_time: float = datetime(2020, 5, 22, 14, 20, 50).timestamp() def sleep(self, seconds: float) -> None: self._current_time += seconds def time(self) -> float: return self._current_time def patch(self, monkeypatch: MonkeyPatch) -> None: from _pytest import timing # noqa: PLW0406 monkeypatch.setattr(timing, "sleep", self.sleep) monkeypatch.setattr(timing, "time", self.time) monkeypatch.setattr(timing, "perf_counter", self.time) __all__ = ["perf_counter", "sleep", "time"]
Save
cmd:
run