Fix block_throw silently returning whole file when token matches with… · rnorth/mkdocs-codeinclude-plugin@048fecb
@@ -46,6 +46,28 @@ def test_block_throw(self):
4646result = select(CODE_BLOCK_EXAMPLE, "test_file", inside_block="nonexistent_block", block_throw=True)
4747484849+def test_block_throw_when_token_matches_but_no_braces(self):
50+"""block_throw should raise when a token appears on a line without braces,
51+ rather than silently returning the whole file."""
52+text = textwrap.dedent("""
53+ void call_foo();
54+ int x = 1;
55+ """)
56+57+with self.assertRaises(ValueError):
58+select(text, "test_file", block="foo", block_throw=True)
59+60+def test_inside_block_throw_when_token_matches_but_no_braces(self):
61+"""inside_block with block_throw should raise when the token appears
62+ on a line without braces, rather than silently returning the whole file."""
63+text = textwrap.dedent("""
64+ void call_foo();
65+ int x = 1;
66+ """)
67+68+with self.assertRaises(ValueError):
69+select(text, "test_file", inside_block="foo", block_throw=True)
70+4971def test_block_curly_on_same_line(self):
5072result = select(
5173textwrap.dedent(