Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7483120

Browse files
committed
ENH: add spin smoke-docs command
1 parent 1afbd5e commit 7483120

2 files changed

Lines changed: 105 additions & 0 deletions

File tree

.spin/cmds.py

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,110 @@ def test(ctx, pytest_args, markexpr, n_jobs, tests, verbose, *args, **kwargs):
258258
ctx.forward(meson.test)
259259

260260

261+
@click.command()
262+
@click.argument("pytest_args", nargs=-1)
263+
@click.option(
264+
"-m",
265+
"markexpr",
266+
metavar='MARKEXPR',
267+
default="not slow",
268+
help="Run tests with the given markers"
269+
)
270+
@click.option(
271+
"-j",
272+
"n_jobs",
273+
metavar='N_JOBS',
274+
default="1",
275+
help=("Number of parallel jobs for testing. "
276+
"Can be set to `auto` to use all cores.")
277+
)
278+
@click.option(
279+
"--tests", "-t",
280+
metavar='TESTS',
281+
help=("""
282+
Which tests to run. Can be a module, function, class, or method:
283+
284+
\b
285+
numpy.random
286+
numpy.random.tests.test_generator_mt19937
287+
numpy.random.tests.test_generator_mt19937::TestMultivariateHypergeometric
288+
numpy.random.tests.test_generator_mt19937::TestMultivariateHypergeometric::test_edge_cases
289+
\b
290+
""")
291+
)
292+
@click.option(
293+
'--verbose', '-v', is_flag=True, default=False
294+
)
295+
@click.pass_context
296+
def smoke_docs(ctx, pytest_args, markexpr, n_jobs, tests, verbose, *args, **kwargs):
297+
"""🔧 Run tests
298+
299+
PYTEST_ARGS are passed through directly to pytest, e.g.:
300+
301+
spin test -- --pdb
302+
303+
To run tests on a directory or file:
304+
305+
\b
306+
spin test numpy/linalg
307+
spin test numpy/linalg/tests/test_linalg.py
308+
309+
To report the durations of the N slowest tests:
310+
311+
spin test -- --durations=N
312+
313+
To run tests that match a given pattern:
314+
315+
\b
316+
spin test -- -k "geometric"
317+
spin test -- -k "geometric and not rgeometric"
318+
319+
By default, spin will run `-m 'not slow'`. To run the full test suite, use
320+
`spin -m full`
321+
322+
For more, see `pytest --help`.
323+
""" # noqa: E501
324+
if (not pytest_args) and (not tests):
325+
pytest_args = ('numpy',)
326+
327+
if '-m' not in pytest_args:
328+
if markexpr != "full":
329+
pytest_args = ('-m', markexpr) + pytest_args
330+
331+
if (n_jobs != "1") and ('-n' not in pytest_args):
332+
pytest_args = ('-n', str(n_jobs)) + pytest_args
333+
334+
if tests and not ('--pyargs' in pytest_args):
335+
pytest_args = ('--pyargs', tests) + pytest_args
336+
337+
if verbose:
338+
pytest_args = ('-v',) + pytest_args
339+
340+
341+
doctest_args = (
342+
# ignores are for things fail doctest collection (optionals etc)
343+
'--ignore=numpy/distutils',
344+
'--ignore=numpy/_core/cversions.py',
345+
'--ignore=numpy/_pyinstaller',
346+
'--ignore=numpy/random/_examples',
347+
'--ignore=numpy/compat',
348+
'--ignore=numpy/f2py/_backends/_distutils.py',
349+
# turn doctesting on:
350+
'--doctest-modules',
351+
'--doctest-collect=api'
352+
)
353+
354+
pytest_args = pytest_args + doctest_args
355+
356+
ctx.params['pytest_args'] = pytest_args
357+
358+
for extra_param in ('markexpr', 'n_jobs', 'tests', 'verbose'):
359+
del ctx.params[extra_param]
360+
361+
ctx.forward(meson.test)
362+
363+
364+
261365
# From scipy: benchmarks/benchmarks/common.py
262366
def _set_mem_rlimit(max_mem=None):
263367
"""

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,5 +211,6 @@ cli = 'vendored-meson/meson/meson.py'
211211
".spin/cmds.py:docs",
212212
".spin/cmds.py:changelog",
213213
".spin/cmds.py:notes",
214+
".spin/cmds.py:smoke_docs"
214215
]
215216
"Metrics" = [".spin/cmds.py:bench"]

0 commit comments

Comments
 (0)