Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
assert compute_dimensions(51, None, w, h) == (51, 26)
# portrait
w, h = 50, 100
assert compute_dimensions(50, 50, w, h) == (25, 50)
assert compute_dimensions(20, 100, w, h) == (20, 40)
assert compute_dimensions(200, 200, w, h) == (100, 200)
assert compute_dimensions(200, 500, w, h) == (200, 400)
#
assert compute_dimensions(None, 50, w, h) == (25, 50)
assert compute_dimensions(20, None, w, h) == (20, 40)
assert compute_dimensions(None, 200, w, h) == (100, 200)
assert compute_dimensions(200, None, w, h) == (200, 400)
#
assert compute_dimensions(None, 49, w, h) == (25, 49)
assert compute_dimensions(None, 51, w, h) == (26, 51)
assert compute_dimensions(50, 50, w, h) == (50, 25)
assert compute_dimensions(100, 20, w, h) == (40, 20)
assert compute_dimensions(200, 200, w, h) == (200, 100)
assert compute_dimensions(500, 200, w, h) == (400, 200)
# test missing dimension
assert compute_dimensions(50, None, w, h) == (50, 25)
assert compute_dimensions(None, 20, w, h) == (40, 20)
assert compute_dimensions(200, None, w, h) == (200, 100)
assert compute_dimensions(None, 200, w, h) == (400, 200)
# test that rounding is half-up
assert compute_dimensions(49, None, w, h) == (49, 25)
assert compute_dimensions(51, None, w, h) == (51, 26)
# portrait
w, h = 50, 100
assert compute_dimensions(50, 50, w, h) == (25, 50)
assert compute_dimensions(20, 100, w, h) == (20, 40)
assert compute_dimensions(200, 200, w, h) == (100, 200)
assert compute_dimensions(200, 500, w, h) == (200, 400)
#
assert compute_dimensions(None, 50, w, h) == (25, 50)
assert compute_dimensions(20, None, w, h) == (20, 40)
assert compute_dimensions(None, 200, w, h) == (100, 200)
assert compute_dimensions(200, None, w, h) == (200, 400)
#
assert compute_dimensions(None, 49, w, h) == (25, 49)
assert compute_dimensions(None, 51, w, h) == (26, 51)
assert compute_dimensions(500, 200, w, h) == (400, 200)
# test missing dimension
assert compute_dimensions(50, None, w, h) == (50, 25)
assert compute_dimensions(None, 20, w, h) == (40, 20)
assert compute_dimensions(200, None, w, h) == (200, 100)
assert compute_dimensions(None, 200, w, h) == (400, 200)
# test that rounding is half-up
assert compute_dimensions(49, None, w, h) == (49, 25)
assert compute_dimensions(51, None, w, h) == (51, 26)
# portrait
w, h = 50, 100
assert compute_dimensions(50, 50, w, h) == (25, 50)
assert compute_dimensions(20, 100, w, h) == (20, 40)
assert compute_dimensions(200, 200, w, h) == (100, 200)
assert compute_dimensions(200, 500, w, h) == (200, 400)
#
assert compute_dimensions(None, 50, w, h) == (25, 50)
assert compute_dimensions(20, None, w, h) == (20, 40)
assert compute_dimensions(None, 200, w, h) == (100, 200)
assert compute_dimensions(200, None, w, h) == (200, 400)
#
assert compute_dimensions(None, 49, w, h) == (25, 49)
assert compute_dimensions(None, 51, w, h) == (26, 51)
def test_dimensions():
# landscape
w, h = 100, 50
assert compute_dimensions(50, 50, w, h) == (50, 25)
assert compute_dimensions(100, 20, w, h) == (40, 20)
assert compute_dimensions(200, 200, w, h) == (200, 100)
assert compute_dimensions(500, 200, w, h) == (400, 200)
# test missing dimension
assert compute_dimensions(50, None, w, h) == (50, 25)
assert compute_dimensions(None, 20, w, h) == (40, 20)
assert compute_dimensions(200, None, w, h) == (200, 100)
assert compute_dimensions(None, 200, w, h) == (400, 200)
# test that rounding is half-up
assert compute_dimensions(49, None, w, h) == (49, 25)
assert compute_dimensions(51, None, w, h) == (51, 26)
# portrait
w, h = 50, 100
assert compute_dimensions(50, 50, w, h) == (25, 50)
assert compute_dimensions(20, 100, w, h) == (20, 40)
assert compute_dimensions(200, 200, w, h) == (100, 200)
assert compute_dimensions(200, 500, w, h) == (200, 400)
#
assert compute_dimensions(None, 50, w, h) == (25, 50)
assert compute_dimensions(20, None, w, h) == (20, 40)
assert compute_dimensions(None, 200, w, h) == (100, 200)
assert compute_dimensions(49, None, w, h) == (49, 25)
assert compute_dimensions(51, None, w, h) == (51, 26)
# portrait
w, h = 50, 100
assert compute_dimensions(50, 50, w, h) == (25, 50)
assert compute_dimensions(20, 100, w, h) == (20, 40)
assert compute_dimensions(200, 200, w, h) == (100, 200)
assert compute_dimensions(200, 500, w, h) == (200, 400)
#
assert compute_dimensions(None, 50, w, h) == (25, 50)
assert compute_dimensions(20, None, w, h) == (20, 40)
assert compute_dimensions(None, 200, w, h) == (100, 200)
assert compute_dimensions(200, None, w, h) == (200, 400)
#
assert compute_dimensions(None, 49, w, h) == (25, 49)
assert compute_dimensions(None, 51, w, h) == (26, 51)
assert compute_dimensions(None, 200, w, h) == (400, 200)
# test that rounding is half-up
assert compute_dimensions(49, None, w, h) == (49, 25)
assert compute_dimensions(51, None, w, h) == (51, 26)
# portrait
w, h = 50, 100
assert compute_dimensions(50, 50, w, h) == (25, 50)
assert compute_dimensions(20, 100, w, h) == (20, 40)
assert compute_dimensions(200, 200, w, h) == (100, 200)
assert compute_dimensions(200, 500, w, h) == (200, 400)
#
assert compute_dimensions(None, 50, w, h) == (25, 50)
assert compute_dimensions(20, None, w, h) == (20, 40)
assert compute_dimensions(None, 200, w, h) == (100, 200)
assert compute_dimensions(200, None, w, h) == (200, 400)
#
assert compute_dimensions(None, 49, w, h) == (25, 49)
assert compute_dimensions(None, 51, w, h) == (26, 51)
def test_dimensions():
# landscape
w, h = 100, 50
assert compute_dimensions(50, 50, w, h) == (50, 25)
assert compute_dimensions(100, 20, w, h) == (40, 20)
assert compute_dimensions(200, 200, w, h) == (200, 100)
assert compute_dimensions(500, 200, w, h) == (400, 200)
# test missing dimension
assert compute_dimensions(50, None, w, h) == (50, 25)
assert compute_dimensions(None, 20, w, h) == (40, 20)
assert compute_dimensions(200, None, w, h) == (200, 100)
assert compute_dimensions(None, 200, w, h) == (400, 200)
# test that rounding is half-up
assert compute_dimensions(49, None, w, h) == (49, 25)
assert compute_dimensions(51, None, w, h) == (51, 26)
# portrait
w, h = 50, 100
assert compute_dimensions(50, 50, w, h) == (25, 50)
assert compute_dimensions(20, 100, w, h) == (20, 40)
assert compute_dimensions(200, 200, w, h) == (100, 200)
assert compute_dimensions(200, 500, w, h) == (200, 400)
#
assert compute_dimensions(None, 50, w, h) == (25, 50)
assert compute_dimensions(20, None, w, h) == (20, 40)
assert compute_dimensions(None, 200, w, h) == (100, 200)
assert compute_dimensions(200, None, w, h) == (200, 400)
#
assert compute_dimensions(None, 49, w, h) == (25, 49)
assert compute_dimensions(None, 51, w, h) == (26, 51)
def test_dimensions():
# landscape
w, h = 100, 50
assert compute_dimensions(50, 50, w, h) == (50, 25)
assert compute_dimensions(100, 20, w, h) == (40, 20)
assert compute_dimensions(200, 200, w, h) == (200, 100)
assert compute_dimensions(500, 200, w, h) == (400, 200)
# test missing dimension
assert compute_dimensions(50, None, w, h) == (50, 25)
assert compute_dimensions(None, 20, w, h) == (40, 20)
assert compute_dimensions(200, None, w, h) == (200, 100)
assert compute_dimensions(None, 200, w, h) == (400, 200)
# test that rounding is half-up
assert compute_dimensions(49, None, w, h) == (49, 25)
assert compute_dimensions(51, None, w, h) == (51, 26)
# portrait
w, h = 50, 100
assert compute_dimensions(50, 50, w, h) == (25, 50)
assert compute_dimensions(20, 100, w, h) == (20, 40)
assert compute_dimensions(200, 200, w, h) == (100, 200)
assert compute_dimensions(200, 500, w, h) == (200, 400)
#
assert compute_dimensions(None, 50, w, h) == (25, 50)
assert compute_dimensions(20, None, w, h) == (20, 40)
assert compute_dimensions(None, 200, w, h) == (100, 200)
assert compute_dimensions(200, None, w, h) == (200, 400)
#
def test_dimensions():
# landscape
w, h = 100, 50
assert compute_dimensions(50, 50, w, h) == (50, 25)
assert compute_dimensions(100, 20, w, h) == (40, 20)
assert compute_dimensions(200, 200, w, h) == (200, 100)
assert compute_dimensions(500, 200, w, h) == (400, 200)
# test missing dimension
assert compute_dimensions(50, None, w, h) == (50, 25)
assert compute_dimensions(None, 20, w, h) == (40, 20)
assert compute_dimensions(200, None, w, h) == (200, 100)
assert compute_dimensions(None, 200, w, h) == (400, 200)
# test that rounding is half-up
assert compute_dimensions(49, None, w, h) == (49, 25)
assert compute_dimensions(51, None, w, h) == (51, 26)
# portrait
w, h = 50, 100
assert compute_dimensions(50, 50, w, h) == (25, 50)
assert compute_dimensions(20, 100, w, h) == (20, 40)
assert compute_dimensions(200, 200, w, h) == (100, 200)
assert compute_dimensions(200, 500, w, h) == (200, 400)
def test_dimensions():
# landscape
w, h = 100, 50
assert compute_dimensions(50, 50, w, h) == (50, 25)
assert compute_dimensions(100, 20, w, h) == (40, 20)
assert compute_dimensions(200, 200, w, h) == (200, 100)
assert compute_dimensions(500, 200, w, h) == (400, 200)
# test missing dimension
assert compute_dimensions(50, None, w, h) == (50, 25)
assert compute_dimensions(None, 20, w, h) == (40, 20)
assert compute_dimensions(200, None, w, h) == (200, 100)
assert compute_dimensions(None, 200, w, h) == (400, 200)
# test that rounding is half-up
assert compute_dimensions(49, None, w, h) == (49, 25)
assert compute_dimensions(51, None, w, h) == (51, 26)
# portrait
w, h = 50, 100
assert compute_dimensions(50, 50, w, h) == (25, 50)
assert compute_dimensions(20, 100, w, h) == (20, 40)
assert compute_dimensions(200, 200, w, h) == (100, 200)
assert compute_dimensions(200, 500, w, h) == (200, 400)
#
assert compute_dimensions(None, 50, w, h) == (25, 50)
assert compute_dimensions(20, None, w, h) == (20, 40)
assert compute_dimensions(None, 200, w, h) == (100, 200)
assert compute_dimensions(200, None, w, h) == (200, 400)