Skip to content

Commit 44f0f25

Browse files
committed
fix: bug in template rendered + add test
1 parent faea5a6 commit 44f0f25

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

tools/schemacode/src/bidsschematools/render/text.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ def make_filename_template(
442442
if placeholders and len(group_lines) == 1:
443443
continue
444444

445-
lines.extend(group_lines)
445+
lines.extend(group_lines)
446446

447447
paragraph = "\n".join(lines)
448448
if pdf_format:

tools/schemacode/src/bidsschematools/tests/test_render_text.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ def test_make_glossary(schema_obj, schema_dir):
6565
assert not any([line.startswith(f'<a name="objects.{i}') for i in rules_only])
6666

6767

68-
def test_make_filename_template(schema_obj, schema_dir):
68+
@pytest.mark.parametrize("placeholders", [True, False])
69+
def test_make_filename_template(schema_obj, schema_dir, placeholders):
6970
"""
7071
Test whether:
7172
@@ -76,7 +77,9 @@ def test_make_filename_template(schema_obj, schema_dir):
7677
* All files under the datatype rules subdirectory have corresponding entries.
7778
This may need to be updated for schema hierarchy changes.
7879
"""
79-
filename_template = text.make_filename_template("raw", schema_obj, pdf_format=True)
80+
filename_template = text.make_filename_template(
81+
"raw", schema_obj, placeholders=placeholders, pdf_format=True
82+
)
8083

8184
# Test predefined substrings
8285
expected_template_part = """
@@ -96,7 +99,9 @@ def test_make_filename_template(schema_obj, schema_dir):
9699
datatype_count = len(datatypes)
97100
datatype_bases = [f" {i}/" for i in datatypes]
98101
datatype_level = False
99-
datatype_file_start = " sub-<label>"
102+
datatype_file_start = (
103+
" sub-<label>" if not placeholders else " <matches>_"
104+
)
100105
datatype_bases_found = 0
101106
for line in filename_template.split("\n"):
102107
if datatype_level:

0 commit comments

Comments
 (0)