def test_fixHeaderBalancing_atx_twoLeft_oneRight(self):

        text = '## Header #'

        expected = '## Header ##'
        actual = header_utils.fix_header_balancing(text)

        self.assertEqual(actual, expected)
    def test_fixHeaderBalancing_setext_tooMany(self):

        text = 'Header\n----------------'

        expected = 'Header\n------'
        actual = header_utils.fix_header_balancing(text)

        self.assertEqual(actual, expected)
    def test_fixHeaderBalancing_setext_unbalanced_alreadyBalanced(self):

        text = 'Header 1\n========'

        expected = 'Header 1\n========'
        actual = header_utils.fix_header_balancing(text, header_utils.UNBALANCED)

        self.assertEqual(actual, expected)
    def test_fixHeaderBalancing_atx_zeroLeft_zeroRight(self):

        text = 'Header'

        expected = 'Header'
        actual = header_utils.fix_header_balancing(text)

        self.assertEqual(actual, expected)
    def test_fixHeaderBalancing_atx_unbalanced_noChange(self):

        text = '# Header 1'

        expected = '# Header 1'
        actual = header_utils.fix_header_balancing(text, header_utils.UNBALANCED)

        self.assertEqual(actual, expected)
    def test_fixHeaderBalancing_atx_unbalanced_rightHeavy(self):

        text = '## Header 2 ###'

        expected = '## Header 2'
        actual = header_utils.fix_header_balancing(text, header_utils.UNBALANCED)

        self.assertEqual(actual, expected)
    def test_fixHeaderBalancing_setext_multiple(self):

        text = 'Header 1\n===\nHeader 2\n----'

        expected = 'Header 1\n========\nHeader 2\n--------'
        actual = header_utils.fix_header_balancing(text)

        self.assertEqual(actual, expected)
    def test_fixHeaderBalancing_setext_notAHeader(self):

        text = 'Header\n***'

        expected = text
        actual = header_utils.fix_header_balancing(text)

        self.assertEqual(actual, expected)
    def test_fixHeaderBalancing_empty(self):

        text = ''

        expected = ''
        actual = header_utils.fix_header_balancing(text)

        self.assertEqual(actual, expected)
    def test_fixHeaderBalancing_setext_alreadyBalanced(self):

        text = 'Header\n------'

        expected = text
        actual = header_utils.fix_header_balancing(text)

        self.assertEqual(actual, expected)
    def test_fixHeaderBalancing_setext_ruleAsAHeader(self):
        """Confirms that rules can be a header title when followed by a setext header line."""

        text = '---\n-------'

        expected = '---\n---'
        actual = header_utils.fix_header_balancing(text)

        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)