Skip to content

Commit 22e71cf

Browse files
committed
Fix pattern suport in graalpytest
1 parent 931babc commit 22e71cf

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

graalpython/com.oracle.graal.python.test/src/graalpytest.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -577,10 +577,12 @@ def run(cls, items=None):
577577
return instance
578578
for k, v in items:
579579
if k.startswith("test"):
580+
testfn = getattr(instance, k, v)
580581
if patterns:
581-
if not any(p in k for p in patterns):
582+
import fnmatch
583+
if not any(fnmatch.fnmatch(testfn.__qualname__, p) for p in patterns):
582584
continue
583-
instance.run_test(getattr(instance, k, v))
585+
instance.run_test(testfn)
584586
if hasattr(instance, "tearDownClass"):
585587
instance.run_safely(instance.tearDownClass)
586588
return instance
@@ -752,7 +754,10 @@ class TextTestResult():
752754
if argv[idx] == "-k":
753755
argv.pop(idx)
754756
try:
755-
patterns.append(argv.pop(idx))
757+
pattern = argv.pop(idx)
758+
if '*' not in pattern:
759+
pattern = '*' + pattern + '*'
760+
patterns.append(pattern)
756761
except IndexError:
757762
print("-k needs an argument")
758763
else:

0 commit comments

Comments
 (0)