def test_rasterize_mismatched_dtype(basic_geometry):

    with Env():
        mismatched_types = (('uint8', 3.2423), ('uint8', -2147483648))
        for dtype, default_value in mismatched_types:
            with pytest.raises(ValueError):
                rasterize(
                    [basic_geometry],
                    out_shape=DEFAULT_SHAPE,
                    default_value=default_value,
                    dtype=dtype
                )

            with pytest.raises(ValueError):
                rasterize(
                    [(basic_geometry, default_value)],
                    out_shape=DEFAULT_SHAPE,
                    dtype=dtype
                )
Mismatched values and dtypes should raise exceptions
dataset/ETHPy150Open mapbox/rasterio/tests/test_features.py/test_rasterize_mismatched_dtype