def test_cycle_u32_3s_1f_raises(self):
        """Test that 32-bit, 3 sample/px data raises exception."""
        ds = dcmread(EXPL_32_3_1F)
        ref = ds.pixel_array
        assert ds.BitsAllocated == 32
        assert ds.SamplesPerPixel == 3

        enc = RLELosslessEncoder
        kwargs = enc.kwargs_from_ds(ds)
        msg = (
            r"The 'gdcm' plugin is unable to RLE encode 32-bit, 3 samples/px "
            r"data with GDCM v3.0.9 or older")
        with pytest.raises(RuntimeError, match=msg):
            gdcm_rle_encode(ds.PixelData, **kwargs)
 def test_encoding_failure_raises(self):
     """Test that a encoding failure result raises an exception"""
     kwargs = {
         'rows': 1,
         'columns': 1,
         'samples_per_pixel': 1,
         'bits_allocated': 8,
         'bits_stored': 8,
         'pixel_representation': 0,
         'number_of_frames': 1,
         'photometric_interpretation': 'PALETTE COLOR',
         'transfer_syntax_uid': ExplicitVRLittleEndian,
     }
     msg = (r"An error occurred with the 'gdcm' plugin: "
            r"unexpected number of fragments found in the 'Pixel Data'")
     with pytest.raises(RuntimeError, match=msg):
         gdcm_rle_encode(b'\x00', **kwargs)
 def test_no_sequence_raises(self):
     """Test that no sequence of fragments raises an exception"""
     kwargs = {
         'rows': 1,
         'columns': 1,
         'samples_per_pixel': 1,
         'bits_allocated': 8,
         'bits_stored': 8,
         'pixel_representation': 0,
         'number_of_frames': 1,
         'photometric_interpretation': 'PALETTE COLOR',
         'transfer_syntax_uid': JPEG2000,
     }
     msg = (
         r"An error occurred with the 'gdcm' plugin: "
         r"ImageChangeTransferSyntax.Change\(\) returned a failure result")
     with pytest.raises(RuntimeError, match=msg):
         gdcm_rle_encode(b'\x00', **kwargs)
 def test_invalid_photometric_interpretation_raises(self):
     """Test an invalid photometric interpretation raises exception"""
     # Its either that or having to debug users getting segfaults
     kwargs = {
         'rows': 1,
         'columns': 1,
         'samples_per_pixel': 1,
         'bits_allocated': 8,
         'bits_stored': 8,
         'pixel_representation': 0,
         'number_of_frames': 1,
         'photometric_interpretation': 'PALETTE_COLOR',
         'transfer_syntax_uid': RLELossless,
     }
     msg = (
         r"An error occurred with the 'gdcm' plugin: invalid photometric "
         r"interpretation 'PALETTE_COLOR'")
     with pytest.raises(ValueError, match=msg):
         gdcm_rle_encode(b'\x00', **kwargs)