|
5 | 5 | import numpy as np
|
6 | 6 | import SharedArray as sa
|
7 | 7 |
|
8 |
| -from mantidimaging.core.parallel.utility import (create_array, execute_impl, free_all_owned_by_this_instance, |
9 |
| - multiprocessing_necessary) |
| 8 | +from mantidimaging.core.parallel.utility import (create_array, create_shared_name, execute_impl, |
| 9 | + free_all_owned_by_this_instance, multiprocessing_necessary) |
10 | 10 |
|
11 | 11 |
|
12 | 12 | def test_correctly_chooses_parallel():
|
@@ -42,19 +42,21 @@ def test_execute_impl_par(mock_pool):
|
42 | 42 |
|
43 | 43 |
|
44 | 44 | def test_free_all_owned_by_this_instance():
|
45 |
| - create_array((10, 10), np.float32, random_name=True) |
46 |
| - create_array((10, 10), np.float32, random_name=True) |
47 |
| - create_array((10, 10), np.float32, random_name=True) |
| 45 | + name1 = create_shared_name() |
| 46 | + name2 = create_shared_name() |
| 47 | + name3 = create_shared_name() |
| 48 | + create_array((10, 10), np.float32, name=name1) |
| 49 | + create_array((10, 10), np.float32, name=name2) |
| 50 | + create_array((10, 10), np.float32, name=name3) |
48 | 51 |
|
49 | 52 | temp_name = "not_this_instance"
|
50 | 53 | sa.create("not_this_instance", (10, 10))
|
51 | 54 |
|
52 |
| - # these tests run in parallel, this should avoid some race conditions at least |
53 |
| - initial = len(sa.list()) |
54 |
| - # frees the 3 allocated above |
55 | 55 | free_all_owned_by_this_instance()
|
56 |
| - expected = initial - 3 |
57 |
| - assert len(sa.list()) == expected |
| 56 | + assert name1 not in [arr.name.decode("utf-8") for arr in sa.list()] |
| 57 | + assert name2 not in [arr.name.decode("utf-8") for arr in sa.list()] |
| 58 | + assert name3 not in [arr.name.decode("utf-8") for arr in sa.list()] |
| 59 | + assert temp_name in [arr.name.decode("utf-8") for arr in sa.list()] |
58 | 60 | sa.delete(temp_name)
|
59 | 61 |
|
60 | 62 |
|
|
0 commit comments