diff --git a/tests/test_tutorials.py b/tests/test_tutorials.py index 8d8c7f7..4853527 100644 --- a/tests/test_tutorials.py +++ b/tests/test_tutorials.py @@ -62,7 +62,8 @@ class TestTutorial(CpuCommonTest): raise ValueError( f"{script_name} should be directly contained in {cls.SUBDIR}" ) - setattr(cls, 'test_' + script_name, _test_tutorial(script_name)) + setattr(cls, 'test_' + osp.splitext(script_name)[0], + _test_tutorial(script_name)) return cls diff --git a/tests/testing_utils.py b/tests/testing_utils.py index 4b07134..d558962 100644 --- a/tests/testing_utils.py +++ b/tests/testing_utils.py @@ -24,13 +24,15 @@ import paddle __all__ = ['CommonTest', 'CpuCommonTest', 'run_script'] -def run_script(cmd, silent=True, wd=None, timeout=None): +def run_script(cmd, silent=True, wd=None, timeout=None, echo=True): # XXX: This function is not safe!!! cfg = dict(check=True, shell=True, timeout=timeout) if silent: cfg['stdout'] = subprocess.DEVNULL if wd is not None: cmd = f"cd {wd} && {cmd}" + if echo: + print(cmd) return subprocess.run(cmd, **cfg)