ultralytics 8.0.175 StreamLoader wait for missing frames (#4814)

This commit is contained in:
Glenn Jocher 2023-09-10 23:59:43 +02:00 committed by GitHub
parent dd0782bd8d
commit 3c88bebc95
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 197 additions and 49 deletions

View file

@ -12,26 +12,46 @@ TMP = (ROOT / '../tests/tmp').resolve() # temp directory for test files
def pytest_addoption(parser):
parser.addoption('--runslow', action='store_true', default=False, help='run slow tests')
"""Add custom command-line options to pytest.
Args:
parser (pytest.config.Parser): The pytest parser object.
"""
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_collection_modifyitems(config, items):
if config.getoption('--runslow'):
# --runslow given in cli: do not skip slow tests
return
skip_slow = pytest.mark.skip(reason='need --runslow option to run')
for item in items:
if 'slow' in item.keywords:
item.add_marker(skip_slow)
"""Modify collected test items based on custom command-line options.
Args:
config (pytest.config.Config): The pytest config object.
items (list): List of collected test items.
"""
if not config.getoption('--slow'):
skip_slow = pytest.mark.skip(reason="remove this test because it's slow")
for item in items:
if 'slow' in item.keywords:
item.add_marker(skip_slow)
def pytest_sessionstart(session):
"""
Called after the 'Session' object has been created and before performing test collection.
Initialize session configurations for pytest.
This function is automatically called by pytest after the 'Session' object has been created but before performing
test collection. It sets the initial seeds and prepares the temporary directory for the test session.
Args:
session (pytest.Session): The pytest session object.
"""
init_seeds()
shutil.rmtree(TMP, ignore_errors=True) # delete any existing tests/tmp directory
@ -39,6 +59,17 @@ def pytest_sessionstart(session):
def pytest_terminal_summary(terminalreporter, exitstatus, config):
"""
Cleanup operations after pytest session.
This function is automatically called by pytest at the end of the entire test session. It removes certain files
and directories used during testing.
Args:
terminalreporter (pytest.terminal.TerminalReporter): The terminal reporter object.
exitstatus (int): The exit status of the test run.
config (pytest.config.Config): The pytest config object.
"""
# Remove files
for file in ['bus.jpg', 'decelera_landscape_min.mov']:
Path(file).unlink(missing_ok=True)