def test_nodata_callback_nan(data): ctx = MockContext() assert math.isnan(nodata_handler(ctx, MockOption('nodata'), 'nan'))
def test_nodata_callback_none(data, value): ctx = MockContext() assert nodata_handler(ctx, MockOption('nodata'), value) is None
def test_nodata_callback_0(data): ctx = MockContext() assert nodata_handler(ctx, MockOption('nodata'), '0') == 0.0
def test_nodata_callback_neg1(data): ctx = MockContext() assert nodata_handler(ctx, MockOption('nodata'), '-1.') == -1.0
def test_nodata_callback_err(data): ctx = MockContext() with pytest.raises(click.BadParameter): nodata_handler(ctx, MockOption('nodata'), '')
def test_nodata_callback_pass(data): """Always return None if the value is None""" ctx = MockContext() assert nodata_handler(ctx, MockOption('nodata'), None) is None
def test_nodata_callback(data): ctx = MockContext() ctx.obj['like'] = {'nodata': -1} assert nodata_handler(ctx, MockOption('nodata'), 'like') == -1.0
def test_nodata_callback_err(data): ctx = MockContext() ctx.obj['like'] = {'nodata': 'lolwut'} with pytest.raises(click.BadParameter): nodata_handler(ctx, MockOption('nodata'), 'lolwut')