diff --git a/tools/schemacode/bidsschematools/tests/test_rules.py b/tools/schemacode/bidsschematools/tests/test_rules.py index 693c4b24fe..529c8e779a 100644 --- a/tools/schemacode/bidsschematools/tests/test_rules.py +++ b/tools/schemacode/bidsschematools/tests/test_rules.py @@ -84,7 +84,7 @@ def test_split_inheritance_rules(): def test_stem_rule(): rule = Namespace.build({"stem": "README", "level": "required", "extensions": ["", ".md"]}) assert rules._stem_rule(rule) == { - "regex": r"README(?P|\.md)", + "regex": r"(?s:README)(?P|\.md)\Z", "mandatory": True, } @@ -92,7 +92,21 @@ def test_stem_rule(): {"stem": "participants", "level": "optional", "extensions": [".tsv", ".json"]} ) assert rules._stem_rule(rule) == { - "regex": r"participants(?P\.tsv|\.json)", + "regex": r"(?s:participants)(?P\.tsv|\.json)\Z", + "mandatory": False, + } + + # Wildcard stem, with datatype + rule = Namespace.build( + { + "stem": "*", + "datatypes": ["phenotype"], + "level": "optional", + "extensions": [".tsv", ".json"], + } + ) + assert rules._stem_rule(rule) == { + "regex": r"(?Pphenotype)/(?s:.*)(?P\.tsv|\.json)\Z", "mandatory": False, }