Skip to content

Commit

Permalink
cover code in the contextvars counter
Browse files Browse the repository at this point in the history
  • Loading branch information
graingert committed Dec 20, 2024
1 parent badc910 commit a57247a
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/trio/_core/_tests/test_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from contextlib import ExitStack, contextmanager, suppress
from math import inf, nan
from typing import TYPE_CHECKING, NoReturn, TypeVar
from unittest import mock

import outcome
import pytest
Expand All @@ -26,7 +27,7 @@
assert_checkpoints,
wait_all_tasks_blocked,
)
from .._run import DEADLINE_HEAP_MIN_PRUNE_THRESHOLD
from .._run import DEADLINE_HEAP_MIN_PRUNE_THRESHOLD, _count_context_run_tb_frames
from .tutil import (
check_sequence_matches,
create_asyncio_future_in_new_loop,
Expand Down Expand Up @@ -2845,3 +2846,12 @@ async def handle_error() -> None:

assert isinstance(exc, MyException)
assert gc.get_referrers(exc) == no_other_refs()


def test_context_run_tb_frames() -> None:
class Context:
def run(self, fn: Callable[[], object]) -> object:
return fn()

with mock.patch("trio._core._run.copy_context", return_value=Context()):
assert _count_context_run_tb_frames() == 1

0 comments on commit a57247a

Please sign in to comment.