def test_viewer_open_no_plugin(tmp_path): viewer = ViewerModel() fname = tmp_path / 'gibberish.gbrsh' fname.touch() with pytest.raises(ValueError) as e: viewer.open(fname) assert 'No plugin found capable of reading' in str(e.value)
def test_viewer_open_no_plugin(tmp_path): viewer = ViewerModel() fname = tmp_path / 'gibberish.gbrsh' fname.touch() with pytest.raises(ValueError, match='No plugin found capable of reading'): # will default to builtins viewer.open(fname)
def test_viewer_open_no_plugin(tmp_path): viewer = ViewerModel() fname = tmp_path / 'gibberish.gbrsh' fname.touch() with pytest.raises(ValueError) as e: # will default to builtins viewer.open(fname) assert "Plugin 'builtins' does not support file(s)" in str(e.value)
def test_viewer_open(): """Test that a plugin to returning nothing adds nothing to the Viewer.""" viewer = ViewerModel() assert len(viewer.layers) == 0 viewer.open('mock_path') assert len(viewer.layers) == 1 viewer.open('mock_path', stack=True) assert len(viewer.layers) == 2
def test_viewer_open(): """Test that a plugin to returning an image adds stuff to the viewer.""" viewer = ViewerModel() assert len(viewer.layers) == 0 viewer.open('mock_path.tif') assert len(viewer.layers) == 1 # The name should be taken from the path name, stripped of extension assert viewer.layers[0].name == 'mock_path' # stack=True also works... and very long names are truncated viewer.open('mock_path.tif', stack=True) assert len(viewer.layers) == 2 assert viewer.layers[1].name.startswith('mock_path')