|
1 | 1 | # TODO: How to enable switching out backend and still run the same tests? |
2 | | -import warnings |
3 | 2 |
|
4 | 3 | import pytest |
5 | 4 |
|
@@ -65,7 +64,6 @@ def _get_marker_names_as_set(self): |
65 | 64 | def test_default_marker_names(self): |
66 | 65 | # Check only that default names are set to a non-empty string |
67 | 66 | assert self.image.DEFAULT_MARKER_NAME |
68 | | - assert self.image.DEFAULT_INTERACTIVE_MARKER_NAME |
69 | 67 |
|
70 | 68 | def test_width_height(self): |
71 | 69 | assert self.image.image_width == 250 |
@@ -125,75 +123,15 @@ def test_zoom(self): |
125 | 123 | self.image.zoom(2) |
126 | 124 | assert self.image.zoom_level == 6 # 3 x 2 |
127 | 125 |
|
128 | | - def test_marking_operations(self): |
129 | | - marks = self.image.get_markers(marker_name="all") |
130 | | - self._assert_empty_marker_table(marks) |
131 | | - assert not self.image.is_marking |
132 | | - |
133 | | - # Ensure you cannot set it like this. |
134 | | - with pytest.raises(AttributeError): |
135 | | - self.image.is_marking = True |
136 | | - |
137 | | - # Setting these to check that start_marking affects them. |
138 | | - self.image.click_center = True # Disables click_drag |
139 | | - assert self.image.click_center |
140 | | - self.image.scroll_pan = False |
141 | | - assert not self.image.scroll_pan |
142 | | - |
| 126 | + def test_marker_properties(self): |
143 | 127 | # Set the marker style |
144 | 128 | marker_style = {'color': 'yellow', 'radius': 10, 'type': 'cross'} |
145 | 129 | self.image.marker = marker_style |
146 | 130 | m_str = str(self.image.marker) |
147 | 131 | for key in marker_style.keys(): |
148 | 132 | assert key in m_str |
149 | 133 |
|
150 | | - self.image.start_marking(marker_name='markymark', marker=marker_style) |
151 | | - assert self.image.is_marking |
152 | | - assert self.image.marker == marker_style |
153 | | - assert not self.image.click_center |
154 | | - assert not self.image.click_drag |
155 | | - |
156 | | - # scroll_pan better activate when marking otherwise there is |
157 | | - # no way to pan while interactively marking |
158 | | - assert self.image.scroll_pan |
159 | | - |
160 | | - # Make sure that when we stop_marking we get our old controls back. |
161 | | - self.image.stop_marking() |
162 | | - assert self.image.click_center |
163 | | - assert not self.image.click_drag |
164 | | - assert not self.image.scroll_pan |
165 | | - |
166 | | - # Make sure no warning is issued when trying to retrieve markers |
167 | | - # with a name that does not exist. |
168 | | - with warnings.catch_warnings(): |
169 | | - warnings.simplefilter("error") |
170 | | - t = self.image.get_markers(marker_name='markymark') |
171 | | - |
172 | | - self._assert_empty_marker_table(t) |
173 | | - |
174 | | - self.image.click_drag = True |
175 | | - self.image.start_marking() |
176 | | - assert not self.image.click_drag |
177 | | - |
178 | | - # Add a marker to the interactive marking table |
179 | | - self.image.add_markers( |
180 | | - Table(data=[[50], [50]], names=['x', 'y'], dtype=('float', 'float')), |
181 | | - marker_name=self.image.DEFAULT_INTERACTIVE_MARKER_NAME, |
182 | | - ) |
183 | | - assert self._get_marker_names_as_set() == set([self.image.DEFAULT_INTERACTIVE_MARKER_NAME]) |
184 | | - |
185 | | - # Clear markers to not pollute other tests. |
186 | | - self.image.stop_marking(clear_markers=True) |
187 | | - |
188 | | - assert self.image.is_marking is False |
189 | | - self._assert_empty_marker_table(self.image.get_markers(marker_name="all")) |
190 | | - |
191 | | - # Hate this, should add to public API |
192 | | - marknames = self._get_marker_names_as_set() |
193 | | - assert len(marknames) == 0 |
194 | | - |
195 | | - # Make sure that click_drag is restored as expected |
196 | | - assert self.image.click_drag |
| 134 | + # TODO: add test that checks that retrieving markers with an unknown name issues no error |
197 | 135 |
|
198 | 136 | def test_add_markers(self): |
199 | 137 | original_marker_name = self.image.DEFAULT_MARKER_NAME |
@@ -391,29 +329,21 @@ def test_click_drag(self): |
391 | 329 |
|
392 | 330 | # If is_marking is true then trying to enable click_drag should fail |
393 | 331 | self.image.click_drag = False |
394 | | - self.image.start_marking() |
395 | | - with pytest.raises(ValueError, match=r'([Ii]nteractive marking)|(while in marking mode)|(while marking is active)'): |
396 | | - self.image.click_drag = True |
397 | | - self.image.stop_marking() |
398 | 332 |
|
399 | 333 | def test_click_center(self): |
400 | 334 | # Set this to ensure that click_center turns it off |
401 | 335 | self.image.click_drag = True |
402 | 336 |
|
403 | 337 | # Make sure that setting click_center to False does not turn off |
404 | | - # click_draf. |
| 338 | + # click_drag. |
405 | 339 | self.image.click_center = False |
406 | 340 | assert self.image.click_drag |
407 | 341 |
|
408 | 342 | self.image.click_center = True |
409 | 343 | assert not self.image.click_drag |
410 | 344 |
|
411 | 345 | self.image.click_center = False |
412 | | - # If is_marking is true then trying to enable click_center should fail |
413 | | - self.image.start_marking() |
414 | | - with pytest.raises(ValueError, match=r'([Ii]nteractive marking)|(while marking is active)'): |
415 | | - self.image.click_center = True |
416 | | - self.image.stop_marking() |
| 346 | + |
417 | 347 |
|
418 | 348 | def test_scroll_pan(self): |
419 | 349 | # Make sure scroll_pan is actually settable |
|
0 commit comments