MCPcopy
hub / github.com/scikit-learn/scikit-learn / pytest_configure

Function pytest_configure

sklearn/conftest.py:440–489  ·  view source on GitHub ↗
(config)

Source from the content-addressed store, hash-verified

438
439
440def pytest_configure(config):
441 # Use matplotlib agg backend during the tests including doctests
442 try:
443 import matplotlib
444
445 matplotlib.use("agg")
446 except ImportError:
447 pass
448
449 allowed_parallelism = joblib.cpu_count(only_physical_cores=True)
450 xdist_worker_count = environ.get("PYTEST_XDIST_WORKER_COUNT")
451 if xdist_worker_count is not None:
452 # Set the number of OpenMP and BLAS threads based on the number of workers
453 # xdist is using to prevent oversubscription.
454 allowed_parallelism = max(allowed_parallelism // int(xdist_worker_count), 1)
455 threadpool_limits(allowed_parallelism)
456
457 if environ.get("SKLEARN_WARNINGS_AS_ERRORS", "0") != "0":
458 # This seems like the only way to programmatically change the config
459 # filterwarnings. This was suggested in
460 # https://github.com/pytest-dev/pytest/issues/3311#issuecomment-373177592
461 for line in get_pytest_filterwarning_lines():
462 config.addinivalue_line("filterwarnings", line)
463
464 if config.option.check_spmatrix:
465 # Note: this patches scipy.sparse to raise upon outdated spmatrix usage
466 # If you run into this with new PR code to sklearn, make sure it:
467 # - converts spmatrix input to sparray
468 # - uses the sparray interface for manipulating the sparse object
469 # - uses align_api_if_sparse(X) just before returning a sparse object
470 munge_scipy_to_check_spmatrix_usage()
471
472 if not PARALLEL_RUN_AVAILABLE:
473 config.addinivalue_line(
474 "markers",
475 "parallel_threads(n): run the given test function in parallel "
476 "using `n` threads.",
477 )
478 config.addinivalue_line(
479 "markers",
480 "thread_unsafe: mark the test function as single-threaded",
481 )
482 config.addinivalue_line(
483 "markers",
484 "iterations(n): run the given test function `n` times in each thread",
485 )
486 config.addinivalue_line(
487 "markers",
488 "iterations(n): run the given test function `n` times in each thread",
489 )
490
491
492@pytest.fixture

Callers

nothing calls this directly

Calls 4

maxFunction · 0.85
getMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…