def test_advanced_uncrunch(): assert uncrunch("50:0-1,3-4;3:2,5;60:6;70:7-8") == [ "50", "50", "3", "50", "50", "3", "60", "70", "70", ]
def page_aspect_ratio(self, page): """Return the aspect ratio for a given page""" default = 0.77 if not self.page_spec: return default try: dimensions = uncrunch(self.page_spec)[page] except (ValueError, KeyError): return default width, height = [float(d) for d in dimensions.split("x")] return width / height
def test_basic_uncrunch(): assert uncrunch("1:0;2:1;3:2") == ["1", "2", "3"]
def test_single_item_uncrunch(): assert uncrunch("77:0") == ["77"]
def test_empty_uncrunch(): assert uncrunch("") == []
def test_order_uncrunch(): assert uncrunch("2:0;1:1") == ["2", "1"]
def test_basic_broken_run_uncrunch(): assert uncrunch("1:0,2;2:1") == ["1", "2", "1"]
def test_basic_run_uncrunch(): assert uncrunch("1:0-2") == ["1", "1", "1"]