MCPcopy
hub / github.com/saltstack/salt / run_pattern

Function run_pattern

tools/testsuite/pytest.py:171–212  ·  view source on GitHub ↗

Run tests matching a pattern (uses pytest -k). Examples: * Run all tests with 'auth' in the name: tools ts pytest pattern auth * Run pattern in specific directory: tools ts pytest pattern loader --test-path tests/pytests/unit * Run pattern with verbose

(
    ctx: Context,
    pattern: str,
    venv: str = None,
    test_path: str = None,
    args: list[str] = None,
)

Source from the content-addressed store, hash-verified

169 },
170)
171def run_pattern(
172 ctx: Context,
173 pattern: str,
174 venv: str = None,
175 test_path: str = None,
176 args: list[str] = None,
177):
178 """
179 Run tests matching a pattern (uses pytest -k).
180
181 Examples:
182
183 * Run all tests with 'auth' in the name:
184
185 tools ts pytest pattern auth
186
187 * Run pattern in specific directory:
188
189 tools ts pytest pattern loader --test-path tests/pytests/unit
190
191 * Run pattern with verbose output:
192
193 tools ts pytest pattern auth --args -v -x
194 """
195 if TYPE_CHECKING:
196 assert pattern is not None
197
198 pytest_bin = get_pytest_path(ctx, venv)
199 if pytest_bin is None:
200 ctx.exit(1)
201
202 # Default to pytests directory if no path specified
203 if test_path is None:
204 test_path = "tests/pytests"
205
206 cmd = [str(pytest_bin), test_path, "-k", pattern]
207 if args:
208 cmd.extend(args)
209
210 ctx.info(f"Running: {' '.join(cmd)}")
211 ret = ctx.run(*cmd, check=False, cwd=tools.utils.REPO_ROOT)
212 ctx.exit(ret.returncode)
213
214
215@pytest_cmd.command(

Callers

nothing calls this directly

Calls 5

get_pytest_pathFunction · 0.85
exitMethod · 0.80
extendMethod · 0.45
infoMethod · 0.45
runMethod · 0.45

Tested by

no test coverage detected