def test_convertBolds_boldAndItalics_sameCharacter_noChange(self): text = '___BoldAndItalics___' character = '_' expected = '___BoldAndItalics___' actual = bold_utils.convert_bolds(text, character) self.assertEqual(actual, expected)
def test_convertBolds_empty(self): text = '' character = '*' expected = '' actual = bold_utils.convert_bolds(text, character) self.assertEqual(actual, expected)
def test_convertBolds_italics(self): text = '_Italics_' character = '*' expected = '_Italics_' actual = bold_utils.convert_bolds(text, character) self.assertEqual(actual, expected)
def test_convertBolds_singleCharacter(self): text = '__B__' character = '*' expected = '**B**' actual = bold_utils.convert_bolds(text, character) self.assertEqual(actual, expected)
def test_convertBolds_fromOtherCharacter_asterisk(self): text = '**Bold**' character = '_' expected = '__Bold__' actual = bold_utils.convert_bolds(text, character) self.assertEqual(actual, expected)
def test_convertBolds_boldedBlankString(self): text = '__ __' character = '*' expected = '__ __' actual = bold_utils.convert_bolds(text, character) self.assertEqual(actual, expected)
def test_convertBolds_noChange(self): text = '**Bold**' character = '*' expected = '**Bold**' actual = bold_utils.convert_bolds(text, character) self.assertEqual(actual, expected)
def test_convertBolds_fourDelimiters(self): text = '____lots of delimiters____' character = '*' expected = '**__lots of delimiters__**' actual = bold_utils.convert_bolds(text, character) self.assertEqual(actual, expected)
def test_convertBold_wrappedTextEndsWithSpace(self): text = '__ends with space __' character = '*' expected = '__ends with space __' actual = bold_utils.convert_bolds(text, character) self.assertEqual(actual, expected)
def test_convertItalics_boldAndItalics_noChange(self): text = '_**BoldAndItalics**_' character = '*' expected = '_**BoldAndItalics**_' actual = bold_utils.convert_bolds(text, character) self.assertEqual(actual, expected)
def test_cleanToClean(self): with open(CLEAN_FILE_PATH) as clean_file: expected = clean_file.read() actual = bold_utils.convert_bolds(expected) actual = header_utils.fix_header_balancing(actual) actual = horizontal_rule_utils.convert_horizontal_rules(actual) actual = italic_utils.convert_italics(actual) actual = link_utils.discover_missing_links(actual) actual = link_utils.format_link_reference_definitions(actual) actual = list_utils.alternate_unordered_list_delimiters(actual) actual = list_utils.fix_ordered_list_numbering(actual) actual = whitespace_utils.trim_nonbreaking_whitespace(actual) self.assertEqual(actual, expected)
def test_dirtyToClean_atx_unbalanced(self): with open(DIRTY_FILE_PATH) as dirty_file: text = dirty_file.read() with open(CLEAN_ANY_HEADER_UNBALANCED_FILE_PATH) as clean_file: expected = clean_file.read() actual = bold_utils.convert_bolds(text) actual = header_utils.fix_header_balancing(actual, balancing=header_utils.UNBALANCED) actual = horizontal_rule_utils.convert_horizontal_rules(actual) actual = italic_utils.convert_italics(actual) actual = link_utils.discover_missing_links(actual) actual = link_utils.format_link_reference_definitions(actual) actual = list_utils.alternate_unordered_list_delimiters(actual) actual = list_utils.fix_ordered_list_numbering(actual) actual = whitespace_utils.trim_nonbreaking_whitespace(actual) self.assertEqual(actual, expected)
def test_convertBolds_wrongCharacter(self): with self.assertRaisesRegex(AssertionError, 'character must be one of *'): bold_utils.convert_bolds('', '^')
def modify(self, text): """Converts any bold implementation into the one defined in the settings.""" bold_character = pretty_markdown.settings().get('bold_character') return bold_utils.convert_bolds(text, bold_character)