Update pyproject.toml [tool.pytest.ini_options] (#9259)

Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>
This commit is contained in:
Glenn Jocher 2024-03-24 02:54:25 +01:00 committed by GitHub
parent 33607ca278
commit 8d31c50856
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 25 deletions

View File

@ -140,9 +140,13 @@ package-data = { "ultralytics" = ["**/*.yaml"], "ultralytics.assets" = ["*.jpg"]
[tool.setuptools.dynamic]
version = { attr = "ultralytics.__version__" }
[tool.pytest]
norecursedirs = [".git", "dist", "build"]
[tool.pytest.ini_options]
addopts = "--doctest-modules --durations=30 --color=yes"
markers = [
"slow: skip slow tests unless --slow is set",
]
norecursedirs = [".git", "dist", "build"]
[tool.coverage.run]
source = ["ultralytics/"]

View File

@ -3,8 +3,6 @@
import shutil
from pathlib import Path
import pytest
TMP = Path(__file__).resolve().parent / "tmp" # temp directory for test files
@ -18,27 +16,6 @@ def pytest_addoption(parser):
parser.addoption("--slow", action="store_true", default=False, help="Run slow tests")
def pytest_configure(config):
"""
Register custom markers to avoid pytest warnings.
Args:
config (pytest.config.Config): The pytest config object.
"""
config.addinivalue_line("markers", "slow: mark test as slow to run")
def pytest_runtest_setup(item):
"""
Setup hook to skip tests marked as slow if the --slow option is not provided.
Args:
item (pytest.Item): The test item object.
"""
if "slow" in item.keywords and not item.config.getoption("--slow"):
pytest.skip("skip slow tests unless --slow is set")
def pytest_collection_modifyitems(config, items):
"""
Modify the list of test items to remove tests marked as slow if the --slow option is not provided.