def test_close_on_last_layer_remove(self):
        # regression test for 391

        d1 = Data(x=np.random.random((2,) * self.ndim))
        d2 = Data(y=np.random.random((2,) * self.ndim))
        dc = DataCollection([d1, d2])
        app = GlueApplication(dc)
        with patch.object(self.widget_cls, 'close') as close:
            w = app.new_data_viewer(self.widget_cls, data=d1)
            w.add_data(d2)
            dc.remove(d1)
            dc.remove(d2)
        assert close.call_count >= 1
dataset/ETHPy150Open glue-viz/glue/glue/viewers/common/qt/tests/test_data_viewer.py/BaseTestDataViewer.test_close_on_last_layer_remove/original