MCPcopy Create free account
hub / github.com/pyca/cryptography / test_basic

Method test_basic

tests/test_rust_utils.py:12–44  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

10
11class TestFixedPool:
12 def test_basic(self):
13 c = 0
14 events = []
15
16 def create():
17 nonlocal c
18 c += 1
19 events.append(("create", c))
20 return c
21
22 pool = FixedPool(create)
23 assert events == [("create", 1)]
24 with pool.acquire() as c:
25 assert c == 1
26 assert events == [("create", 1)]
27
28 with pool.acquire() as c:
29 assert c == 2
30 assert events == [("create", 1), ("create", 2)]
31
32 assert events == [("create", 1), ("create", 2)]
33
34 assert events == [("create", 1), ("create", 2)]
35
36 del pool
37 gc.collect()
38 gc.collect()
39 gc.collect()
40
41 assert events == [
42 ("create", 1),
43 ("create", 2),
44 ]
45
46 def test_thread_stress(self):
47 def create():

Callers

nothing calls this directly

Calls 2

acquireMethod · 0.95
FixedPoolClass · 0.85

Tested by

no test coverage detected