Check allocation stats on *pool*.
(pool)
| 60 | |
| 61 | |
| 62 | def check_allocated_bytes(pool): |
| 63 | """ |
| 64 | Check allocation stats on *pool*. |
| 65 | """ |
| 66 | allocated_before = pool.bytes_allocated() |
| 67 | max_mem_before = pool.max_memory() |
| 68 | num_allocations_before = pool.num_allocations() |
| 69 | with allocate_bytes(pool, 512): |
| 70 | assert pool.bytes_allocated() == allocated_before + 512 |
| 71 | new_max_memory = pool.max_memory() |
| 72 | assert pool.max_memory() >= max_mem_before |
| 73 | num_allocations_after = pool.num_allocations() |
| 74 | assert num_allocations_after > num_allocations_before |
| 75 | assert num_allocations_after < num_allocations_before + 5 |
| 76 | assert pool.bytes_allocated() == allocated_before |
| 77 | assert pool.max_memory() == new_max_memory |
| 78 | assert pool.num_allocations() == num_allocations_after |
| 79 | |
| 80 | |
| 81 | def test_default_allocated_bytes(): |
no test coverage detected