22
33import pytest
44
5+ from traitlets .traitlets import TraitError
6+
57from astropy .io import fits
68from astropy .nddata import NDData
79from astropy .table import Table
@@ -43,11 +45,11 @@ def test_center_on():
4345 image .center_on ((x , y ))
4446
4547
46- def test_offset_to ():
48+ def test_offset_by ():
4749 image = ImageWidget ()
4850 dx = 10
4951 dy = 10
50- image .offset_to (dx , dy )
52+ image .offset_by (dx , dy )
5153
5254
5355def test_zoom_level ():
@@ -72,15 +74,15 @@ def test_select_points():
7274
7375def test_get_selection ():
7476 image = ImageWidget ()
75- marks = image .get_markers ()
77+ marks = image .get_all_markers ()
7678 assert isinstance (marks , Table ) or marks is None
7779
7880
7981def test_stop_marking ():
8082 image = ImageWidget ()
8183 # This is not much of a test...
8284 image .stop_marking (clear_markers = True )
83- assert image .get_markers () is None
85+ assert image .get_all_markers () is None
8486 assert image .is_marking is False
8587
8688
@@ -147,7 +149,7 @@ def test_set_markers():
147149 assert '10' in str (image .marker )
148150
149151
150- def test_reset_markers ():
152+ def test_remove_all_markers ():
151153 image = ImageWidget ()
152154 # First test: this shouldn't raise any errors
153155 # (it also doesn't *do* anything...)
@@ -159,11 +161,11 @@ def test_reset_markers():
159161 skycoord_colname = 'coord' , marker_name = 'test' )
160162 image .add_markers (table , x_colname = 'x' , y_colname = 'y' ,
161163 skycoord_colname = 'coord' , marker_name = 'test2' )
162- image .reset_markers ()
164+ image .remove_all_markers ()
163165 with pytest .raises (ValueError ):
164- image .get_markers (marker_name = 'test' )
166+ image .get_markers_by_name (marker_name = 'test' )
165167 with pytest .raises (ValueError ):
166- image .get_markers (marker_name = 'test2' )
168+ image .get_markers_by_name (marker_name = 'test2' )
167169
168170
169171def test_remove_markers_by_name ():
@@ -183,10 +185,15 @@ def test_remove_markers_by_name():
183185
184186def test_stretch ():
185187 image = ImageWidget ()
188+ data = np .random .random ([100 , 100 ])
189+ # image.load_array(data)
186190 with pytest .raises (ValueError ) as e :
187191 image .stretch = 'not a valid value'
188192 assert 'must be one of' in str (e .value )
189-
193+ # 👇👇👇👇 handle this case more gracefully 👇👇👇
194+ # (no data set, so finding the limits fails)
195+ # (should probably record the choice, then apply)
196+ # (when data is loaded)
190197 image .stretch = 'log'
191198 assert isinstance (image .stretch , (BaseStretch , str ))
192199
@@ -230,7 +237,7 @@ def test_colormap():
230237def test_cursor ():
231238 image = ImageWidget ()
232239 assert image .cursor in ALLOWED_CURSOR_LOCATIONS
233- with pytest .raises (ValueError ):
240+ with pytest .raises (TraitError ):
234241 image .cursor = 'not a valid option'
235242 image .cursor = 'bottom'
236243 assert image .cursor == 'bottom'
@@ -294,7 +301,7 @@ def test_scroll_pan():
294301def test_save ():
295302 image = ImageWidget ()
296303 filename = 'woot.png'
297- image .save (filename )
304+ image .save (filename , overwrite = True )
298305
299306
300307def test_width_height ():
0 commit comments