timeout_option_fixture.py 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  1. """
  2. Copyright (c) Contributors to the Open 3D Engine Project.
  3. For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. SPDX-License-Identifier: Apache-2.0 OR MIT
  5. Pytest fixture for accessing an optional "--timeout" argument used for specifying
  6. the timeout (in seconds) for any one AP Batch call.
  7. If not specified, defaults to 35 minutes
  8. """
  9. import pytest
  10. import logging
  11. logger = logging.getLogger(__name__)
  12. @pytest.fixture(scope="session")
  13. def timeout_option_fixture(request) -> int:
  14. """
  15. Fixture for accessing the command line argument "--ap_timeout"
  16. Defaults to 35 minutes
  17. """
  18. default_timeout = 35 * 60 # 35 minutes (2100 seconds)
  19. timeout = request.config.getoption("--ap_timeout")
  20. if timeout is not None:
  21. try:
  22. return int(timeout)
  23. except ValueError:
  24. # failed casting timeout to integer
  25. # fmt:off
  26. logger.error(f"Failed parsing --ap_timeout cmdline argument {timeout} to integer. "
  27. f"Using default value of {default_timeout} seconds")
  28. # fmt:on
  29. return default_timeout