(capture)
| 243 | |
| 244 | |
| 245 | def test_numpy_view(capture): |
| 246 | with capture: |
| 247 | ac = m.ArrayClass() |
| 248 | ac_view_1 = ac.numpy_view() |
| 249 | ac_view_2 = ac.numpy_view() |
| 250 | assert np.all(ac_view_1 == np.array([1, 2], dtype=np.int32)) |
| 251 | del ac |
| 252 | pytest.gc_collect() |
| 253 | assert ( |
| 254 | capture |
| 255 | == """ |
| 256 | ArrayClass() |
| 257 | ArrayClass::numpy_view() |
| 258 | ArrayClass::numpy_view() |
| 259 | """ |
| 260 | ) |
| 261 | ac_view_1[0] = 4 |
| 262 | ac_view_1[1] = 3 |
| 263 | assert ac_view_2[0] == 4 |
| 264 | assert ac_view_2[1] == 3 |
| 265 | with capture: |
| 266 | del ac_view_1 |
| 267 | del ac_view_2 |
| 268 | pytest.gc_collect() |
| 269 | pytest.gc_collect() |
| 270 | assert ( |
| 271 | capture |
| 272 | == """ |
| 273 | ~ArrayClass() |
| 274 | """ |
| 275 | ) |
| 276 | |
| 277 | |
| 278 | def test_cast_numpy_int64_to_uint64(): |
nothing calls this directly
no test coverage detected