def test_dtype_rescaling_uint16(tmpdir):
    # NB: 255 * 16 is 4080, we don't actually get to 4095.
    outputname = str(tmpdir.join('test.tif'))
    runner = CliRunner()
    result = runner.invoke(convert, [
        'tests/data/RGB.byte.tif', outputname, '--dtype', 'uint16',
        '--scale-ratio', '16'])
    assert result.exit_code == 0
    with rasterio.open(outputname) as src:
        for band in src.read():
            assert round(band.min() - 0, 6) == 0.0
            assert round(band.max() - 4080, 6) == 0.0
Rescale uint8 [0, 255] to uint16 [0, 4095]
dataset/ETHPy150Open mapbox/rasterio/tests/test_rio_convert.py/test_dtype_rescaling_uint16