This is an automated email from the ASF dual-hosted git repository. tomaz pushed a commit to branch dependabot/pip/pytest-8.0.2 in repository https://gitbox.apache.org/repos/asf/libcloud.git
commit a52f5d9f6dca7850e74fa4bb2b56653d5f6401a2 Author: Tomaz Muraus <to...@tomaz.me> AuthorDate: Tue Apr 16 18:20:09 2024 +0200 Try a workaround for tests which started failing with new pytest version (>= 8.0). In theory with mocking in place, those tests should be safe to run in parallel, but because of some reason, they are prone to race condition, but only with pytest >= 8.0.0. To avoid this race condition, we now run tests which are not thread safe separately at the end in non parallel fashion. Tests which are not safe to run in parallel are marked with "serial" pytest marker. --- libcloud/test/test_init.py | 3 +++ tox.ini | 5 ++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/libcloud/test/test_init.py b/libcloud/test/test_init.py index 7eccd4550..07ca57ca8 100644 --- a/libcloud/test/test_init.py +++ b/libcloud/test/test_init.py @@ -20,6 +20,7 @@ import tempfile from unittest import mock from unittest.mock import patch +import pytest import libcloud from libcloud import _init_once, reset_debug from libcloud.base import DriverTypeNotFoundError @@ -48,6 +49,7 @@ class TestUtils(unittest.TestCase): paramiko_logger.setLevel(logging.INFO) @mock.patch.dict(os.environ, {"LIBCLOUD_DEBUG": ""}, clear=True) + @pytest.mark.serial def test_init_once_and_no_debug_mode(self): if have_paramiko: paramiko_logger = logging.getLogger("paramiko") @@ -68,6 +70,7 @@ class TestUtils(unittest.TestCase): self.assertEqual(paramiko_log_level, logging.INFO) @mock.patch.dict(os.environ, {"LIBCLOUD_DEBUG": TEMP_LOGFILE_PATH}, clear=True) + @pytest.mark.serial def test_init_once_and_debug_mode(self): if have_paramiko: paramiko_logger = logging.getLogger("paramiko") diff --git a/tox.ini b/tox.ini index 9dcc2f406..a1dc82195 100644 --- a/tox.ini +++ b/tox.ini @@ -37,8 +37,11 @@ setenv = # To avoid per-test function process safety issues we run all tests in a single # file in the same worker process. # for pytest-xdist, we want to distribute tests by file aka --dist loadfile +# Tests which are not safe to run in paralell are marked with "serial" tag +# and run separately at the end commands = cp libcloud/test/secrets.py-dist libcloud/test/secrets.py - pytest --color=yes -rsx -vvv --capture=tee-sys -o log_cli=True --durations=10 --timeout=15 -n auto --dist loadfile --ignore libcloud/test/benchmarks/ --ignore-glob "*test_list_objects_filtering_performance*" + pytest --color=yes -rsx -vvv --capture=tee-sys -o log_cli=True --durations=10 --timeout=15 -n auto --dist loadfile --ignore libcloud/test/benchmarks/ --ignore-glob "*test_list_objects_filtering_performance*" -m "not serial" + pytest --color=yes -rsx -vvv --capture=tee-sys -o log_cli=True --durations=10 --timeout=15 --ignore libcloud/test/benchmarks/ --ignore-glob "*test_list_objects_filtering_performance*" -m "serial" [testenv:py3.8-dist] # Verify library installs without any dependencies when using python setup.py