Skip to content

Commit

Permalink
Regression test for #1614
Browse files Browse the repository at this point in the history
which I confirmed that it fails without this patch.

Mark line to be excluded from bandit check.

Update result for affected remote test.
  • Loading branch information
pllim committed Sep 16, 2022
1 parent 1bd3d38 commit 54e6b3e
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
2 changes: 1 addition & 1 deletion jdaviz/configs/imviz/tests/test_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ def test_parse_jwst_nircam_level2(self, imviz_helper):

imviz_helper.load_data(pf, ext='SCI', data_label='TEST', show_in_viewer=False)
data = imviz_helper.app.data_collection[1]
assert data.label.endswith('[DATA]_2')
assert data.label.endswith('[DATA] 1')

# Load all extensions
imviz_helper.app.data_collection.clear()
Expand Down
23 changes: 23 additions & 0 deletions jdaviz/configs/imviz/tests/test_viewers.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import numpy as np
import pytest
from regions import CirclePixelRegion, PixCoord

from jdaviz.app import Application
from jdaviz.core.config import get_configuration
Expand Down Expand Up @@ -34,6 +35,28 @@ def test_destroy_viewer_invalid(imviz_helper):
assert imviz_helper.app.get_viewer_ids() == ['imviz-0']


def test_destroy_viewer_with_subset(imviz_helper):
"""Regression test for https://github.com/spacetelescope/jdaviz/issues/1614"""
arr = np.ones((10, 10))
imviz_helper.load_data(arr, data_label='my_array')

# Create a second viewer.
imviz_helper.create_image_viewer(viewer_name='second')

# Add existing data to second viewer.
imviz_helper.app.add_data_to_viewer('second', 'my_array')

# Create a Subset.
reg = CirclePixelRegion(center=PixCoord(x=4, y=4), radius=2)
imviz_helper.load_regions(reg)

# Remove the second viewer.
imviz_helper.destroy_viewer('second')

# Delete the Subset: Should have no traceback.
imviz_helper._delete_region('Subset 1')


def test_mastviz_config():
"""Use case from https://github.com/spacetelescope/jdaviz/issues/1037"""

Expand Down
2 changes: 1 addition & 1 deletion jdaviz/core/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -682,7 +682,7 @@ def _next_subset_num(label_prefix, subset_groups):
i_str = sub_label[-1]
try:
i = int(i_str)
except Exception:
except Exception: # nosec
continue
else:
if i > max_i:
Expand Down

0 comments on commit 54e6b3e

Please sign in to comment.