Whole file

nschloe/pytest-codeblocks

The author described this change as fix for indented blocks. It counts as a record because the check below fails on the code as it stood at c476f3090 and passes on db2835e4c, with nothing else changed between the two runs.

Fix saved2020-10-10
Sharing licenceMIT · LICENSE.txt
Change size+8 3

What the code was meant to do, written into the code itself as a save note

fix for indented blocks

The change

1515 # EOF
1616 break
1717
18- if line.strip()[:3] == "```":
19- syntax = line.strip()[3:]
18+ if line.lstrip()[:3] == "```":
19+ syntax = line.lstrip()[3:]
20+ num_leading_spaces = len(line) - len(line.lstrip())
2021 lineno = k - 1
2122 # read the block
2223 code_block = []
2930 raise RuntimeError(
3031 f"File too large (> {max_num_lines} lines). Set max_num_lines."
3132 )
32- if line.strip()[:3] == "```":
33+ # check if end of block
34+ if line.lstrip()[:3] == "```":
3335 break
36+ # Cut (at most) num_leading_spaces leading spaces
37+ nls = min(num_leading_spaces, len(line) - len(line.lstrip()))
38+ line = line[nls:]
3439 code_block.append(line)
3540
3641 if syntax_filter and syntax_filter.strip() != syntax.strip():

The check that tells the two apart

failpass·test/test_exdown.py::test_reference

Check file test/test_exdown.py, taken without changes from the fix and copied onto the older code, so the exact same check runs against both versions.

Origin and history

The code before itc476f3090b33ed642cc1aaf320148170f377cdfd
Broken version dated2020-10-10
Moduleexdown.main
Units changedfrom_buffer
Fingerprint01c1bdbda3a59a1a
Checked2026-08-18 by goldset/0.1

Every field above is generated by our program. None of it is written by hand.

Other bugs found in nschloe/pytest-codeblocks