Beispiel #1
0
def test_md047_all_samples():
    """
    Test to make sure we get the expected behavior after scanning the files in the
    test/resources/rules/md047 directory.
    """

    # Arrange
    scanner = MarkdownScanner()
    supplied_arguments = ["scan", "test/resources/rules/md047"]

    expected_return_code = 1
    expected_output = (
        "test/resources/rules/md047/end_with_no_blank_line.md:3:41: " +
        "MD047: Each file should end with a single newline character. " +
        "(single-trailing-newline)\n" +
        "test/resources/rules/md047/end_with_no_blank_line_and_spaces.md:4:2: "
        + "MD047: Each file should end with a single newline character. " +
        "(single-trailing-newline)\n")
    expected_error = ""

    # Act
    execute_results = scanner.invoke_main(arguments=supplied_arguments)

    # Assert
    execute_results.assert_results(expected_output, expected_error,
                                   expected_return_code)
def test_md030_bad_configuration_ul_multi():
    """
    Test to verify that a configuration error is thrown when supplying the
    ul_multi value with a string that is not an integer.
    """

    # Arrange
    scanner = MarkdownScanner()
    supplied_arguments = [
        "--set",
        "plugins.md030.ul_multi=not-integer",
        "--strict-config",
        "scan",
        "test/resources/rules/md030/good_one_list.md",
    ]

    expected_return_code = 1
    expected_output = ""
    expected_error = (
        "BadPluginError encountered while configuring plugins:\n" +
        "The value for property 'plugins.md030.ul_multi' must be of type 'int'."
    )

    # Act
    execute_results = scanner.invoke_main(arguments=supplied_arguments)

    # Assert
    execute_results.assert_results(expected_output, expected_error,
                                   expected_return_code)
Beispiel #3
0
def test_md005_good_ordered_list_double_level_right():
    """
    Test to make sure this rule does not trigger with a document that
    has two level 1 ordered lists with consistent indentation and right alignment.
    """

    # Arrange
    scanner = MarkdownScanner()
    supplied_arguments = [
        "--disable-rules",
        "md029",
        "scan",
        "test/resources/rules/md005/good_ordered_list_double_level_right.md",
    ]

    expected_return_code = 0
    expected_output = ""
    expected_error = ""

    # Act
    execute_results = scanner.invoke_main(arguments=supplied_arguments)

    # Assert
    execute_results.assert_results(expected_output, expected_error,
                                   expected_return_code)
def test_md030_good_spacing_ul_double_config_1_2():
    """
    Test to make sure this rule does trigger with a document that
    contains single-paragraph unordered lists with one space after the marker,
    and configuration.
    """

    # Arrange
    scanner = MarkdownScanner()
    supplied_arguments = [
        "--set",
        "plugins.md030.ul_single=$#1",
        "--set",
        "plugins.md030.ul_multi=$#2",
        "--strict-config",
        "scan",
        "test/resources/rules/md030/good_spacing_ul_double.md",
    ]

    expected_return_code = 1
    expected_output = (
        "test/resources/rules/md030/good_spacing_ul_double.md:2:1: " +
        "MD030: Spaces after list markers " +
        "[Expected: 2; Actual: 1] (list-marker-space)")
    expected_error = ""

    # Act
    execute_results = scanner.invoke_main(arguments=supplied_arguments)

    # Assert
    execute_results.assert_results(expected_output, expected_error,
                                   expected_return_code)
def test_md030_bad_spacing_ul_double():
    """
    Test to make sure this rule does trigger with a document that
    contains single-paragraph unordered lists with two space after the marker.
    """

    # Arrange
    scanner = MarkdownScanner()
    supplied_arguments = [
        "--disable-rules",
        "md007",
        "--stack-trace",
        "scan",
        "test/resources/rules/md030/bad_spacing_ul_double.md",
    ]

    expected_return_code = 1
    expected_output = (
        "test/resources/rules/md030/bad_spacing_ul_double.md:1:1: " +
        "MD030: Spaces after list markers " +
        "[Expected: 1; Actual: 2] (list-marker-space)\n" +
        "test/resources/rules/md030/bad_spacing_ul_double.md:2:1: " +
        "MD030: Spaces after list markers " +
        "[Expected: 1; Actual: 2] (list-marker-space)\n" +
        "test/resources/rules/md030/bad_spacing_ul_double.md:5:1: " +
        "MD030: Spaces after list markers " +
        "[Expected: 1; Actual: 2] (list-marker-space)")
    expected_error = ""

    # Act
    execute_results = scanner.invoke_main(arguments=supplied_arguments)

    # Assert
    execute_results.assert_results(expected_output, expected_error,
                                   expected_return_code)
Beispiel #6
0
def test_md001_front_matter_with_alternate_title():
    """
    Variation of test_md001_front_matter_with_title using configuration
    to specify an alternate title.
    """

    # Arrange
    scanner = MarkdownScanner()
    supplied_arguments = [
        "--set",
        "extensions.front-matter.enabled=$!True",
        "--set",
        "plugins.md001.front_matter_title=Subject",
        "scan",
        "test/resources/rules/md001/front_matter_with_alternate_title.md",
    ]

    expected_return_code = 1
    expected_output = "test/resources/rules/md001/front_matter_with_alternate_title.md:5:1: MD001: Heading levels should only increment by one level at a time. [Expected: h2; Actual: h3] (heading-increment,header-increment)\n"
    expected_error = ""

    # Act
    execute_results = scanner.invoke_main(arguments=supplied_arguments)

    # Assert
    execute_results.assert_results(expected_output, expected_error,
                                   expected_return_code)
Beispiel #7
0
def test_md001_bad_configuration_front_matter_title():
    """
    Test to verify that enabling front matter title with number "1" fails.
    """

    # Arrange
    scanner = MarkdownScanner()
    supplied_arguments = [
        "--strict-config",
        "--set",
        "extensions.front-matter.enabled=$!True",
        "--set",
        "plugins.md001.front_matter_title=$#1",
        "scan",
        "test/resources/rules/md001/proper_atx_heading_incrementing.md",
    ]

    expected_return_code = 1
    expected_output = ""
    expected_error = (
        "BadPluginError encountered while configuring plugins:\n" +
        "The value for property 'plugins.md001.front_matter_title' must be of type 'str'."
    )

    # Act
    execute_results = scanner.invoke_main(arguments=supplied_arguments)

    # Assert
    execute_results.assert_results(expected_output, expected_error,
                                   expected_return_code)
Beispiel #8
0
def test_markdown_with_dash_x_init():
    """
    Test to make sure we get simulate a test initialization exception if the
    `-x-init` flag is set.
    """

    # Arrange
    scanner = MarkdownScanner()
    supplied_arguments = [
        "-x-init",
        "scan",
        "test/resources/rules/md047/end_with_no_blank_line.md",
    ]
    fake_directory = "fredo"
    fake_file = "entities.json"
    fake_path = os.path.join(fake_directory, fake_file)
    abs_fake_path = os.path.abspath(fake_path).replace("\\", "\\\\")

    expected_return_code = 1
    expected_output = ""
    expected_error = (
        "BadTokenizationError encountered while initializing tokenizer:\n" +
        "Named character entity map file '" + fake_path + "' was not loaded " +
        "([Errno 2] No such file or directory: '" + abs_fake_path + "').\n")

    # Act
    execute_results = scanner.invoke_main(arguments=supplied_arguments)

    # Assert
    execute_results.assert_results(expected_output, expected_error,
                                   expected_return_code)
Beispiel #9
0
def test_markdown_with_dash_e_single_by_id_and_non_present_config_file():
    """
    Test to make sure we get an error if we provide a configuration file that is
    not in a json format.
    """

    # Arrange
    scanner = MarkdownScanner()
    configuration_file = "not-exists"
    assert not os.path.exists(configuration_file)
    supplied_arguments = [
        "-e",
        "MD999",
        "-c",
        configuration_file,
        "scan",
        "test/resources/rules/md047/end_with_blank_line.md",
    ]

    expected_return_code = 1
    expected_output = ""
    expected_error = (
        "Specified configuration file 'not-exists' was not loaded " +
        "([Errno 2] No such file or directory: 'not-exists').\n")

    # Act
    execute_results = scanner.invoke_main(arguments=supplied_arguments)

    # Assert
    execute_results.assert_results(expected_output, expected_error,
                                   expected_return_code)
Beispiel #10
0
def test_markdown_with_dash_d_and_dash_e_single_by_name():
    """
    Test to make sure we get disabled if a rule if '-d' is supplied
    and if 'e' is supplied, both with the name of the rule.
    The test data for MD047 is used as it is a simple file that
    fails normally, it is used as a comparison.
    """

    # Arrange
    scanner = MarkdownScanner()
    supplied_arguments = [
        "-d",
        "single-trailing-newline",
        "-e",
        "single-trailing-newline",
        "scan",
        "test/resources/rules/md047/end_with_blank_line.md",
    ]

    expected_return_code = 0
    expected_output = ""
    expected_error = ""

    # Act
    execute_results = scanner.invoke_main(arguments=supplied_arguments)

    # Assert
    execute_results.assert_results(expected_output, expected_error,
                                   expected_return_code)
Beispiel #11
0
def test_markdown_with_dash_x_scan():
    """
    Test to make sure we get simulate a test scan exception if the `-x-scan` flag
    is set.
    """

    # Arrange
    scanner = MarkdownScanner()
    supplied_arguments = [
        "-x-scan",
        "scan",
        "test/resources/rules/md047/end_with_no_blank_line.md",
    ]

    expected_return_code = 1
    expected_output = ""
    expected_error = """BadTokenizationError encountered while scanning 'test/resources/rules/md047/end_with_no_blank_line.md':
An unhandled error occurred processing the document.
"""

    # Act
    execute_results = scanner.invoke_main(arguments=supplied_arguments)

    # Assert
    execute_results.assert_results(expected_output, expected_error,
                                   expected_return_code)
Beispiel #12
0
def test_markdown_with_dash_d_single_by_id():
    """
    Test to make sure we get enable a rule if '-d' is supplied and the id of the
    rule is provided. The test data for MD047 is used as it is a simple file that
    fails normally, it is used as a comparison.
    """

    # Arrange
    scanner = MarkdownScanner()
    supplied_arguments = [
        "-d",
        "MD047",
        "scan",
        "test/resources/rules/md047/end_with_no_blank_line.md",
    ]

    expected_return_code = 0
    expected_output = ""
    expected_error = ""

    # Act
    execute_results = scanner.invoke_main(arguments=supplied_arguments)

    # Assert
    execute_results.assert_results(expected_output, expected_error,
                                   expected_return_code)
Beispiel #13
0
def test_markdown_with_bad_strict_config_type():
    """
    Test to make sure that we can set the strict configuration mode from
    the configuration file, capturing any bad errors.
    """

    # Arrange
    scanner = MarkdownScanner()
    supplied_configuration = {"mode": {"strict-config": 2}}
    configuration_file = None
    try:
        configuration_file = write_temporary_configuration(
            supplied_configuration)
        supplied_arguments = [
            "-c",
            configuration_file,
            "scan",
            "test/resources/rules/md047/end_with_blank_line.md",
        ]

        expected_return_code = 1
        expected_output = ""
        expected_error = "Configuration Error: The value for property 'mode.strict-config' must be of type 'bool'."

        # Act
        execute_results = scanner.invoke_main(arguments=supplied_arguments)

        # Assert
        execute_results.assert_results(expected_output, expected_error,
                                       expected_return_code)
    finally:
        if configuration_file and os.path.exists(configuration_file):
            os.remove(configuration_file)
Beispiel #14
0
def test_md047_bad_end_with_blank_line_containing_spaces():
    """
    Test to make sure this rule does trigger with a document that
    ends with a line that is only whitespace.
    """

    # Arrange
    scanner = MarkdownScanner()
    supplied_arguments = [
        "scan",
        "test/resources/rules/md047/end_with_no_blank_line_and_spaces.md",
    ]

    expected_return_code = 1
    expected_output = (
        "test/resources/rules/md047/end_with_no_blank_line_and_spaces.md:4:2: "
        +
        "MD047: Each file should end with a single newline character. (single-trailing-newline)\n"
    )
    expected_error = ""

    # Act
    execute_results = scanner.invoke_main(arguments=supplied_arguments)

    # Assert
    execute_results.assert_results(expected_output, expected_error,
                                   expected_return_code)
Beispiel #15
0
def test_md001_front_matter_with_no_title():
    """
    Test to make sure the rule does not trigger with a document with
    a front-matter element with no title and the front matter extension
    enabled, and a following Atx Heading of level 3.
    """

    # Arrange
    scanner = MarkdownScanner()
    supplied_arguments = [
        "--set",
        "extensions.front-matter.enabled=$!True",
        "scan",
        "test/resources/rules/md001/front_matter_with_no_title.md",
    ]

    expected_return_code = 0
    expected_output = ""
    expected_error = ""

    # Act
    execute_results = scanner.invoke_main(arguments=supplied_arguments)

    # Assert
    execute_results.assert_results(expected_output, expected_error,
                                   expected_return_code)
Beispiel #16
0
def test_md047_bad_end_with_no_blank_line():
    """
    Test to make sure we get the expected behavior after scanning a bad file from the
    test/resources/rules/md047 directory which does not end with a blank line.
    """

    # Arrange
    scanner = MarkdownScanner()
    supplied_arguments = [
        "test/resources/rules/md047/end_with_no_blank_line.md"
    ]

    expected_return_code = 1
    expected_output = (
        "test/resources/rules/md047/end_with_no_blank_line.md:3:41: " +
        "MD047: Files should end with a single newline character (single-trailing-newline)\n"
    )
    expected_error = ""

    # Act
    execute_results = scanner.invoke_main(arguments=supplied_arguments)

    # Assert
    execute_results.assert_results(expected_output, expected_error,
                                   expected_return_code)
Beispiel #17
0
def test_md001_front_matter_with_title():
    """
    Test to make sure the rule does trigger with a document with
    a front-matter element with a title and the front matter extension
    enabled, and a following Atx Heading of level 3.
    """

    # Arrange
    scanner = MarkdownScanner()
    supplied_arguments = [
        "--set",
        "extensions.front-matter.enabled=$!True",
        "scan",
        "test/resources/rules/md001/front_matter_with_title.md",
    ]

    expected_return_code = 1
    expected_output = "test/resources/rules/md001/front_matter_with_title.md:5:1: MD001: Heading levels should only increment by one level at a time. [Expected: h2; Actual: h3] (heading-increment,header-increment)\n"
    expected_error = ""

    # Act
    execute_results = scanner.invoke_main(arguments=supplied_arguments)

    # Assert
    execute_results.assert_results(expected_output, expected_error,
                                   expected_return_code)
Beispiel #18
0
def test_md024_bad_same_heading_content_atx_in_different_block_quotes():
    """
    Test to make sure this rule does trigger with a document that
    contains Atx headings with duplicate content in the different block quotes.
    """

    # Arrange
    scanner = MarkdownScanner()
    supplied_arguments = [
        "--disable-rules",
        "md028",
        "scan",
        "test/resources/rules/md024/same_heading_content_atx_in_different_block_quotes.md",
    ]

    expected_return_code = 1
    expected_output = (
        "test/resources/rules/md024/same_heading_content_atx_in_different_block_quotes.md:3:3: "
        +
        "MD024: Multiple headings cannot contain the same content. (no-duplicate-heading,no-duplicate-header)\n"
    )
    expected_error = ""

    # Act
    execute_results = scanner.invoke_main(arguments=supplied_arguments)

    # Assert
    execute_results.assert_results(expected_output, expected_error,
                                   expected_return_code)
Beispiel #19
0
def test_md001_bad_configuration_enabled():
    """
    Test to verify that enabling front matter with text "True" fails.
    """

    # Arrange
    scanner = MarkdownScanner()
    supplied_arguments = [
        "--strict-config",
        "--set",
        "extensions.front-matter.enabled=True",
        "scan",
        "test/resources/rules/md001/front_matter_with_title.md",
    ]

    expected_return_code = 1
    expected_output = ""
    expected_error = """Configuration error ValueError encountered while initializing extensions:
The value for property 'extensions.front-matter.enabled' must be of type 'bool'."""

    # Act
    execute_results = scanner.invoke_main(arguments=supplied_arguments)

    # Assert
    execute_results.assert_results(expected_output, expected_error,
                                   expected_return_code)
Beispiel #20
0
def test_md024_bad_same_heading_but_not_in_siblings_setext():
    """
    Test to make sure this rule does trigger with a document that
    contains SetExt headings with duplicate content in siblings.
    """

    # Arrange
    scanner = MarkdownScanner()
    supplied_arguments = [
        "--disable-rules",
        "md025",
        "scan",
        "test/resources/rules/md024/same_heading_but_not_in_siblings_setext.md",
    ]

    expected_return_code = 1
    expected_output = (
        "test/resources/rules/md024/same_heading_but_not_in_siblings_setext.md:10:1: "
        +
        "MD024: Multiple headings cannot contain the same content. (no-duplicate-heading,no-duplicate-header)\n"
    )
    expected_error = ""

    # Act
    execute_results = scanner.invoke_main(arguments=supplied_arguments)

    # Assert
    execute_results.assert_results(expected_output, expected_error,
                                   expected_return_code)
def test_md030_bad_spacing_ul_single_config_2_1():
    """
    Test to make sure this rule does not trigger with a document that contains
    unordered lists with two spaces after the marker, and configuration to make
    it okay. ul_multi does not come into effect as all list items have a single
    paragraph.
    """

    # Arrange
    scanner = MarkdownScanner()
    supplied_arguments = [
        "--set",
        "plugins.md030.ul_single=$#2",
        "--set",
        "plugins.md030.ul_multi=$#1",
        "--strict-config",
        "--stack-trace",
        "scan",
        "test/resources/rules/md030/bad_spacing_ul_single.md",
    ]

    expected_return_code = 0
    expected_output = ""
    expected_error = ""

    # Act
    execute_results = scanner.invoke_main(arguments=supplied_arguments)

    # Assert
    execute_results.assert_results(expected_output, expected_error,
                                   expected_return_code)
Beispiel #22
0
def test_md024_good_same_heading_content_setext_with_configuration():
    """
    Test to make sure this rule does trigger with a document that
    contains SetExt headings with duplicate content in siblings with configuration.
    """

    # Arrange
    scanner = MarkdownScanner()
    supplied_configuration = {"plugins": {"md024": {"siblings_only": True}}}
    configuration_file = None
    try:
        configuration_file = write_temporary_configuration(
            supplied_configuration)
        supplied_arguments = [
            "-c",
            configuration_file,
            "scan",
            "test/resources/rules/md024/same_heading_content_setext.md",
        ]

        expected_return_code = 0
        expected_output = ""
        expected_error = ""

        # Act
        execute_results = scanner.invoke_main(arguments=supplied_arguments)

        # Assert
        execute_results.assert_results(expected_output, expected_error,
                                       expected_return_code)
    finally:
        if configuration_file and os.path.exists(configuration_file):
            os.remove(configuration_file)
def test_md030_bad_configuration_ul_single_zero():
    """
    Test to verify that a configuration error is thrown when supplying the
    ul_single value with an integer not greater than 0.
    """

    # Arrange
    scanner = MarkdownScanner()
    supplied_arguments = [
        "--set",
        "plugins.md030.ul_single=$#0",
        "--strict-config",
        "scan",
        "test/resources/rules/md030/good_one_list.md",
    ]

    expected_return_code = 1
    expected_output = ""
    expected_error = (
        "BadPluginError encountered while configuring plugins:\n" +
        "The value for property 'plugins.md030.ul_single' is not valid: Allowable values are any integer greater than 0."
    )

    # Act
    execute_results = scanner.invoke_main(arguments=supplied_arguments)

    # Assert
    execute_results.assert_results(expected_output, expected_error,
                                   expected_return_code)
Beispiel #24
0
def test_md001_empty_configuration_front_matter_title():
    """
    Test to verify that enabling front matter title with "" is okay.
    Note that since nothing in the front matter is considered a title,
    then there is nothing to compare the first heading element to.
    """

    # Arrange
    scanner = MarkdownScanner()
    supplied_arguments = [
        "--strict-config",
        "--set",
        "extensions.front-matter.enabled=$!True",
        "--set",
        "plugins.md001.front_matter_title=",
        "scan",
        "test/resources/rules/md001/front_matter_with_title.md",
    ]

    expected_return_code = 0
    expected_output = ""
    expected_error = ""

    # Act
    execute_results = scanner.invoke_main(arguments=supplied_arguments)

    # Assert
    execute_results.assert_results(expected_output, expected_error,
                                   expected_return_code)
def test_md030_bad_spacing_ul_single_nested_double_2_1():
    """
    Test to make sure this rule does trigger with a document that
    contains nested unordered lists with two space after the marker,
    single-paragraph and nested double-paragraph lists.
    """

    # Arrange
    scanner = MarkdownScanner()
    supplied_arguments = [
        "--set",
        "plugins.md030.ul_single=$#2",
        "--set",
        "plugins.md030.ul_multi=$#1",
        "--strict-config",
        "--disable-rules",
        "md007",
        "scan",
        "test/resources/rules/md030/bad_spacing_ul_single_nested_double.md",
    ]

    expected_return_code = 1
    expected_output = (
        "test/resources/rules/md030/bad_spacing_ul_single_nested_double.md:1:1: "
        + "MD030: Spaces after list markers " +
        "[Expected: 1; Actual: 2] (list-marker-space)")
    expected_error = ""

    # Act
    execute_results = scanner.invoke_main(arguments=supplied_arguments)

    # Assert
    execute_results.assert_results(expected_output, expected_error,
                                   expected_return_code)
Beispiel #26
0
def test_md001_good_proper_setext_heading_incrementing():
    """
    Test to make sure the rule doesn't trigger with a document with
    only SetExt Headings, that when they increase, only increase by 1.
    Note that after the first 2 headings, it switches over to Atx Headings.
    """

    # Arrange
    scanner = MarkdownScanner()
    supplied_arguments = [
        "--disable-rules",
        "MD003",
        "scan",
        "test/resources/rules/md001/proper_setext_heading_incrementing.md",
    ]

    expected_return_code = 0
    expected_output = ""
    expected_error = ""

    # Act
    execute_results = scanner.invoke_main(arguments=supplied_arguments)

    # Assert
    execute_results.assert_results(expected_output, expected_error,
                                   expected_return_code)
Beispiel #27
0
def test_md005_bad_unordered_list_single_level():
    """
    Test to make sure this rule does trigger with a document that
    is only level 1 unordered lists with 1 indent before the second list.
    """

    # Arrange
    scanner = MarkdownScanner()
    supplied_arguments = [
        "--disable-rules",
        "md007",
        "scan",
        "test/resources/rules/md005/bad_unordered_list_single_level.md",
    ]

    expected_return_code = 1
    expected_output = (
        "test/resources/rules/md005/bad_unordered_list_single_level.md:2:2: " +
        "MD005: Inconsistent indentation for list items at the same level " +
        "[Expected: 0; Actual: 1] (list-indent)")
    expected_error = ""

    # Act
    execute_results = scanner.invoke_main(arguments=supplied_arguments)

    # Assert
    execute_results.assert_results(expected_output, expected_error,
                                   expected_return_code)
Beispiel #28
0
def test_md001_bad_improper_setext_heading_incrementing():
    """
    Test to make sure the rule does trigger with a document with
    only SetExt Headings (and Atx Headings after level 2), that when they
    increase, only increase by 2.
    """

    # Arrange
    scanner = MarkdownScanner()
    supplied_arguments = [
        "--disable-rules",
        "MD003",
        "scan",
        "test/resources/rules/md001/improper_setext_heading_incrementing.md",
    ]

    expected_return_code = 1
    expected_output = (
        "test/resources/rules/md001/improper_setext_heading_incrementing.md:4:1: "
        +
        "MD001: Heading levels should only increment by one level at a time. "
        + "[Expected: h3; Actual: h4] (heading-increment,header-increment)\n")
    expected_error = ""

    # Act
    execute_results = scanner.invoke_main(arguments=supplied_arguments)

    # Assert
    execute_results.assert_results(expected_output, expected_error,
                                   expected_return_code)
Beispiel #29
0
def test_md005_bad_ordered_list_double_level_weirder():
    """
    Test to make sure this rule does trigger with a document that
    has two level 1 ordered lists with consistent indentation and weirder alignment.
    """

    # Arrange
    scanner = MarkdownScanner()
    supplied_arguments = [
        "--stack-trace",
        "--disable-rules",
        "md029",
        "scan",
        "test/resources/rules/md005/bad_ordered_list_double_level_weirder.md",
    ]

    expected_return_code = 1
    expected_output = (
        "test/resources/rules/md005/bad_ordered_list_double_level_weirder.md:3:3: "
        + "MD005: Inconsistent indentation for list items at the same level " +
        "[Expected: 0; Actual: 2] (list-indent)")
    expected_error = ""

    # Act
    execute_results = scanner.invoke_main(arguments=supplied_arguments)

    # Assert
    execute_results.assert_results(expected_output, expected_error,
                                   expected_return_code)
Beispiel #30
0
def test_md043_bad_good_many_level_two_1_star_3_2_star_3():
    """
    Test to make sure this rule does trigger with a document that
    contains headings and a pattern with a pattern of wildcards and matching headings.
    """

    # Arrange
    scanner = MarkdownScanner()
    supplied_arguments = [
        "--disable-rules",
        "md024",
        "--set",
        "plugins.md043.headings=# Heading 1,*,### Heading 3,## Heading 2,*,### Heading 3",
        "--strict-config",
        "--stack-trace",
        "scan",
        "test/resources/rules/md043/good_many_level_two.md",
    ]

    expected_return_code = 1
    expected_output = (
        "test/resources/rules/md043/good_many_level_two.md:3:1: " +
        "MD043: Required heading structure " +
        "[Multiple wildcard matching failed.] (required-headings,required-headers)"
    )
    expected_error = ""

    # Act
    execute_results = scanner.invoke_main(
        arguments=supplied_arguments, suppress_first_line_heading_rule=False)

    # Assert
    execute_results.assert_results(expected_output, expected_error,
                                   expected_return_code)