def test_detabify_string_building_sequences(): """ TBD - tab stop starts at 5, moves it to 9, second tab stop normal of 4 """ # Arrange input_string = "\t0\t01\t012\t0123\t" expected_output = " 0 01 012 0123 " # Act actual_output = ParserHelper.detabify_string(input_string) # Assert assert expected_output == actual_output
def test_detabify_string_double_tab(): """ TBD """ # Arrange input_string = "\t\t" expected_output = " " # Act actual_output = ParserHelper.detabify_string(input_string) # Assert assert expected_output == actual_output
def test_detabify_string_double_tab_with_four_chars_before_and_after(): """ TBD - tab stop starts at 5, moves it to 9, second tab stop normal of 4 """ # Arrange input_string = "aaaa\t\taaaa" expected_output = "aaaa aaaa" # Act actual_output = ParserHelper.detabify_string(input_string) # Assert assert expected_output == actual_output
def test_detabify_string_multiple_spaces(): """ TBD """ # Arrange for i in range(10): input_string = "".rjust(i, " ") # Act actual_output = ParserHelper.detabify_string(input_string) # Assert assert input_string == actual_output
def verify_markdown_roundtrip(source_markdown, actual_tokens): """ Verify that we can use the information in the tokens to do a round trip back to the original Markdown that created the token. """ if "\t" in source_markdown: new_source = [] split_source = source_markdown.split(ParserHelper.newline_character) for next_line in split_source: if "\t" in next_line: next_line = ParserHelper.detabify_string(next_line) new_source.append(next_line) source_markdown = ParserHelper.newline_character.join(new_source) transformer = TransformToMarkdown() original_markdown = transformer.transform(actual_tokens) print( "".join( [ "\n-=-=-\nExpected\n-=-=-\n-->", ParserHelper.make_value_visible(source_markdown), "<--\n-=-=-\nActual\n-=-=-\n-->", ParserHelper.make_value_visible(original_markdown), "<--\n-=-=-\n", ] ) ) diff = difflib.ndiff(source_markdown, original_markdown) diff_values = "".join( [ "\n-=-=-n", ParserHelper.newline_character.join(list(diff)), "\n-=-=-expected\n-->", ParserHelper.make_value_visible(source_markdown), "<--\n-=-=-actual\n-->", ParserHelper.make_value_visible(original_markdown), "<--\n-=-=-\n", ] ) assert ( source_markdown == original_markdown ), f"Markdown strings are not equal.{diff_values}"