def test_get_correct_width_wrong_raw_str(): ctx = Context() ctx.image_width_str = 'x9pm' with pytest.raises(ValueError) as exc: image._get_correct_width(ctx) assert 'x9pm' in exc
def test_get_correct_width_wrong_unit(): ctx = Context() ctx.image_width_str = '9pm' ctx.image_max_width = 300 with pytest.raises(ValueError): image._get_correct_width(ctx)
def test_shrink(): ctx = Context() ctx.image_width_str = '50cm' ctx.image_max_width = 20 image._get_correct_width(ctx) assert ctx.image_width == 20
def test_get_correct_width(width_str): ctx = Context() ctx.image_width_str = width_str ctx.image_max_width = 300 image._get_correct_width(ctx) assert ctx.image_width <= 300