File: test_class_release_gil_before_calling_cpp_dtor.py

package info (click to toggle)
pybind11 3.0.1-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 4,448 kB
  • sloc: cpp: 27,239; python: 13,512; ansic: 4,244; makefile: 204; sh: 36
file content (21 lines) | stat: -rw-r--r-- 567 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
from __future__ import annotations

import gc

import pytest

from pybind11_tests import class_release_gil_before_calling_cpp_dtor as m


@pytest.mark.parametrize(
    ("probe_type", "unique_key", "expected_result"),
    [
        (m.ProbeType0, "without_manipulating_gil", "1"),
        (m.ProbeType1, "release_gil_before_calling_cpp_dtor", "0"),
    ],
)
def test_gil_state_check_results(probe_type, unique_key, expected_result):
    probe_type(unique_key)
    gc.collect()
    result = m.PopPyGILState_Check_Result(unique_key)
    assert result == expected_result