Skip to content

Commit

Permalink
#450 - Fixed issues with consistency checks disabled for pragmas
Browse files Browse the repository at this point in the history
  • Loading branch information
jackdewinter committed Aug 25, 2022
1 parent b537553 commit 8f152a2
Show file tree
Hide file tree
Showing 10 changed files with 93 additions and 87 deletions.
2 changes: 0 additions & 2 deletions issues.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@

## Priority 2 - Like To Solve Before Initial

- pragma tests need to remove `disable_consistency_checks=True`

- make sure to generated ordered/unordered tests to make sure both covered
- every unordered tests should have an ordered counterpart
- every ordered tests should have an unordered counterpart
Expand Down
4 changes: 2 additions & 2 deletions publish/coverage.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"totalCovered": 3519
},
"lineLevel": {
"totalMeasured": 12281,
"totalCovered": 12281
"totalMeasured": 12285,
"totalCovered": 12285
}
}

16 changes: 8 additions & 8 deletions publish/test-results.json
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,14 @@
"skippedTests": 0,
"elapsedTimeInMilliseconds": 0
},
{
"name": "test.extensions.test_markdown_pragma_parsing",
"totalTests": 12,
"failedTests": 0,
"errorTests": 0,
"skippedTests": 0,
"elapsedTimeInMilliseconds": 0
},
{
"name": "test.extensions.test_markdown_pragmas",
"totalTests": 13,
Expand Down Expand Up @@ -410,14 +418,6 @@
"skippedTests": 0,
"elapsedTimeInMilliseconds": 0
},
{
"name": "test.gfm.test_markdown_html_blocks_extra",
"totalTests": 12,
"failedTests": 0,
"errorTests": 0,
"skippedTests": 0,
"elapsedTimeInMilliseconds": 0
},
{
"name": "test.gfm.test_markdown_image_links",
"totalTests": 30,
Expand Down
6 changes: 2 additions & 4 deletions pymarkdown/container_block_leaf_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -883,12 +883,10 @@ def __calculate_current_indent_level(
last_list_index = 0
had_non_block_token = False
did_hit_indent_level_threshold = False
POGGER.debug_with_visible_whitespace("token-stack:$:", parser_state.token_stack)
POGGER.debug("token-stack:$:", parser_state.token_stack)
for current_stack_index in range(1, len(parser_state.token_stack)):
proposed_indent_level = 0
POGGER.debug_with_visible_whitespace(
"token:$:", parser_state.token_stack[current_stack_index]
)
POGGER.debug("token:$:", parser_state.token_stack[current_stack_index])
if parser_state.token_stack[current_stack_index].is_block_quote:
last_list_index = 0
(
Expand Down
4 changes: 4 additions & 0 deletions pymarkdown/extensions/pragma_token.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ def look_for_pragmas(
Look for a pragma in the current line.
"""

POGGER.debug("look_for_pragmas - >$<", line_to_parse)
POGGER.debug("look_for_pragmas - ws >$<", extracted_whitespace)
if (
not container_depth
and not extracted_whitespace
Expand Down Expand Up @@ -97,7 +99,9 @@ def look_for_pragmas(
else position_marker.line_number
)
parser_properties.pragma_lines[index_number] = line_to_parse
POGGER.debug("pragma $ extracted - >$<", index_number, line_to_parse)
return True
POGGER.debug("pragma not extracted - >$<", line_to_parse)
return False

# pylint: disable=too-many-locals, too-many-arguments
Expand Down
1 change: 1 addition & 0 deletions pymarkdown/parser_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,7 @@ def make_value_visible(value_to_modify: Any) -> str:
str(value_to_modify)
.replace(ParserHelper.__backspace_character, "\\b")
.replace(ParserHelper.__alert_character, "\\a")
.replace(ParserHelper.tab_character, "\\t")
.replace(ParserHelper.newline_character, "\\n")
.replace(ParserHelper.whitespace_split_character, "\\x02")
.replace(ParserHelper.replace_noop_character, "\\x03")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""
https://github.github.com/gfm/#html-blocks
Pragmas
"""
from test.utils import act_and_assert

Expand All @@ -9,7 +9,7 @@


@pytest.mark.gfm
def test_html_blocks_extrax_01():
def test_pragma_parsing_01():
"""
Test case 01: Pragma alone in a document.
"""
Expand All @@ -20,13 +20,11 @@ def test_html_blocks_extrax_01():
expected_gfm = """"""

# Act & Assert
act_and_assert(
source_markdown, expected_gfm, expected_tokens, disable_consistency_checks=True
)
act_and_assert(source_markdown, expected_gfm, expected_tokens)


@pytest.mark.gfm
def test_html_blocks_extrax_02():
def test_pragma_parsing_02():
"""
Test case 02: Pargma within a paragraph.
"""
Expand All @@ -48,13 +46,11 @@ def test_html_blocks_extrax_02():
expected_gfm = """<p>This is a paragraph\nstill a paragraph\nand still going.</p>"""

# Act & Assert
act_and_assert(
source_markdown, expected_gfm, expected_tokens, disable_consistency_checks=True
)
act_and_assert(source_markdown, expected_gfm, expected_tokens)


@pytest.mark.gfm
def test_html_blocks_extrax_03():
def test_pragma_parsing_03():
"""
Test case 03: Pragma at the start and end of the document.
"""
Expand All @@ -74,13 +70,11 @@ def test_html_blocks_extrax_03():
expected_gfm = """<p>This is a paragraph\nstill a paragraph\nand still going.</p>"""

# Act & Assert
act_and_assert(
source_markdown, expected_gfm, expected_tokens, disable_consistency_checks=True
)
act_and_assert(source_markdown, expected_gfm, expected_tokens)


@pytest.mark.gfm
def test_html_blocks_extrax_03a():
def test_pragma_parsing_03a():
"""
Test case 03a: Pragma at start and end with a single line paragraph.
"""
Expand All @@ -98,13 +92,11 @@ def test_html_blocks_extrax_03a():
expected_gfm = """<p>This is a paragraph.</p>"""

# Act & Assert
act_and_assert(
source_markdown, expected_gfm, expected_tokens, disable_consistency_checks=True
)
act_and_assert(source_markdown, expected_gfm, expected_tokens)


@pytest.mark.gfm
def test_html_blocks_extrax_04():
def test_pragma_parsing_04():
"""
Test case 04: Only two pragmas in entire document.
"""
Expand All @@ -116,13 +108,11 @@ def test_html_blocks_extrax_04():
expected_gfm = ""

# Act & Assert
act_and_assert(
source_markdown, expected_gfm, expected_tokens, disable_consistency_checks=True
)
act_and_assert(source_markdown, expected_gfm, expected_tokens)


@pytest.mark.gfm
def test_html_blocks_extrax_05():
def test_pragma_parsing_05():
"""
Test case 05: Single line paragraph with double pragmas to start and end document.
"""
Expand All @@ -142,13 +132,11 @@ def test_html_blocks_extrax_05():
expected_gfm = "<p>this is a paragraph</p>"

# Act & Assert
act_and_assert(
source_markdown, expected_gfm, expected_tokens, disable_consistency_checks=True
)
act_and_assert(source_markdown, expected_gfm, expected_tokens)


@pytest.mark.gfm
def test_html_blocks_extrax_06():
def test_pragma_parsing_06():
"""
Test case 06: Verify that an HTML comment followed by the "pyml " title without any whitespace is parsed.
"""
Expand All @@ -167,13 +155,11 @@ def test_html_blocks_extrax_06():
expected_gfm = "<p>this is a paragraph</p>"

# Act & Assert
act_and_assert(
source_markdown, expected_gfm, expected_tokens, disable_consistency_checks=True
)
act_and_assert(source_markdown, expected_gfm, expected_tokens)


@pytest.mark.gfm
def test_html_blocks_extrax_07():
def test_pragma_parsing_07():
"""
Test case 07: Verify that an HTML comment followed by the "pyml " title with multiple whitespace is parsed.
"""
Expand All @@ -192,13 +178,11 @@ def test_html_blocks_extrax_07():
expected_gfm = "<p>this is a paragraph</p>"

# Act & Assert
act_and_assert(
source_markdown, expected_gfm, expected_tokens, disable_consistency_checks=True
)
act_and_assert(source_markdown, expected_gfm, expected_tokens)


@pytest.mark.gfm
def test_html_blocks_extrax_08():
def test_pragma_parsing_08():
"""
Test case 08: Pragma-like, without the space after the pragma title.
"""
Expand All @@ -219,13 +203,11 @@ def test_html_blocks_extrax_08():
expected_gfm = "<!-- pyml-->\n<p>this is a paragraph</p>"

# Act & Assert
act_and_assert(
source_markdown, expected_gfm, expected_tokens, disable_consistency_checks=True
)
act_and_assert(source_markdown, expected_gfm, expected_tokens)


@pytest.mark.gfm
def test_html_blocks_extrax_09():
def test_pragma_parsing_09():
"""
Test case 08: Pragma-like, without the closing comment sequence.
"""
Expand All @@ -243,13 +225,11 @@ def test_html_blocks_extrax_09():
expected_gfm = "<!-- pyml--\nthis is a paragraph\n"

# Act & Assert
act_and_assert(
source_markdown, expected_gfm, expected_tokens, disable_consistency_checks=True
)
act_and_assert(source_markdown, expected_gfm, expected_tokens)


@pytest.mark.gfm
def test_html_blocks_extrax_010():
def test_pragma_parsing_010():
"""
Test case 10: Pragma heading, but with different casing.
"""
Expand All @@ -268,13 +248,11 @@ def test_html_blocks_extrax_010():
expected_gfm = "<p>this is a paragraph</p>"

# Act & Assert
act_and_assert(
source_markdown, expected_gfm, expected_tokens, disable_consistency_checks=True
)
act_and_assert(source_markdown, expected_gfm, expected_tokens)


@pytest.mark.gfm
def test_html_blocks_extrax_011():
def test_pragma_parsing_011():
"""
Test case 11: Pragma heading, but with extra spacing after the closing comment.
"""
Expand All @@ -295,6 +273,4 @@ def test_html_blocks_extrax_011():
expected_gfm = "<p>this is a paragraph</p>"

# Act & Assert
act_and_assert(
source_markdown, expected_gfm, expected_tokens, disable_consistency_checks=True
)
act_and_assert(source_markdown, expected_gfm, expected_tokens)
Loading

0 comments on commit 8f152a2

Please sign in to comment.