def test_simple(): sect = get_reference_section_beginning(["Hello", "References", "[1] Ref1"]) assert sect == { 'marker': '[1]', 'marker_pattern': u'\\s*(?P<mark>\\[\\s*(?P<marknum>\\d+)\\s*\\])', 'start_line': 1, 'title_string': 'References', 'title_marker_same_line': False, 'how_found_start': 1, }
def test_no_title_via_numbers2(): sect = get_reference_section_beginning(["Hello", "1", "Ref1", "(3)", "2", "Ref2"]) assert sect, { "marker": "1", "marker_pattern": u"(?P<mark>(?P<left>)\\s*(?P<marknum>\\d+)\\s*(?P<right>))", "start_line": 1, "title_string": None, "title_marker_same_line": False, "how_found_start": 4, }
def test_no_title_via_dots(): sect = get_reference_section_beginning(["Hello", "1. Ref1" "2. Ref2"]) assert sect == { "marker": "1.", "marker_pattern": u"(?P<mark>(?P<left>)\\s*(?P<marknum>\\d+)\\s*(?P<right>\\.))", "start_line": 1, "title_string": None, "title_marker_same_line": False, "how_found_start": 3, }
def test_no_title_via_brackets(): sect = get_reference_section_beginning(["Hello", "[1] Ref1" "[2] Ref2"]) assert sect == { "marker": "[1]", "marker_pattern": u"(?P<mark>(?P<left>\\[)\\s*(?P<marknum>\\d+)\\s*(?P<right>\\]))", "start_line": 1, "title_string": None, "title_marker_same_line": False, "how_found_start": 2, }
def test_simple(): sect = get_reference_section_beginning(["Hello", "References", "[1] Ref1"]) assert sect == { "marker": "[1]", "marker_pattern": u"\\s*(?P<mark>\\[\\s*(?P<marknum>\\d+)\\s*\\])", "start_line": 1, "title_string": "References", "title_marker_same_line": False, "how_found_start": 1, }
def test_no_title_via_numbers(): sect = get_reference_section_beginning(["Hello", "1 Ref1" "2 Ref2"]) assert sect == { 'marker': '1', 'marker_pattern': u'(?P<mark>(?P<left>)\\s*(?P<marknum>\\d+)\\s*(?P<right>))', 'start_line': 1, 'title_string': None, 'title_marker_same_line': False, 'how_found_start': 4, }
def test_no_title_via_brackets(): sect = get_reference_section_beginning(["Hello", "[1] Ref1" "[2] Ref2"]) assert sect == { 'marker': '[1]', 'marker_pattern': u'(?P<mark>(?P<left>\\[)\\s*(?P<marknum>\\d+)\\s*(?P<right>\\]))', 'start_line': 1, 'title_string': None, 'title_marker_same_line': False, 'how_found_start': 2, }
def test_no_section(): sect = get_reference_section_beginning("") assert sect is None