From 893e6deb276d687f05a99c9887237836789a8dd1 Mon Sep 17 00:00:00 2001 From: Mario Ostieri Date: Tue, 4 Feb 2025 13:54:36 +0000 Subject: [PATCH] fix infinite loop --- tests/example_tests/test_coverage_increase.py | 6 ++++-- tests/example_tests/test_dvs.py | 6 ++++-- tests/example_tests/test_libuserd.py | 6 ++++-- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/tests/example_tests/test_coverage_increase.py b/tests/example_tests/test_coverage_increase.py index 1079b90d5bb..41f1bf432e0 100644 --- a/tests/example_tests/test_coverage_increase.py +++ b/tests/example_tests/test_coverage_increase.py @@ -300,7 +300,8 @@ def test_coverage_increase(tmpdir, pytestconfig: pytest.Config): launcher.enshell_log_contents() assert session.ensight.objs.core.PARTS[0] != session.ensight.objs.core.PARTS[1] counter = 0 - while True and counter < 5: + success = False + while not success and counter < 5: try: cas_file = session.download_pyansys_example( "mixing_elbow.cas.h5", "pyfluent/mixing_elbow" @@ -308,10 +309,11 @@ def test_coverage_increase(tmpdir, pytestconfig: pytest.Config): dat_file = session.download_pyansys_example( "mixing_elbow.dat.h5", "pyfluent/mixing_elbow" ) + success = True except Exception: counter += 1 time.sleep(60) - if counter == 5: + if counter == 5 and not success: raise RuntimeError("Couldn't download data from github") session.load_data(cas_file, result_file=dat_file) # diff --git a/tests/example_tests/test_dvs.py b/tests/example_tests/test_dvs.py index 7881bb6a39f..42139e2ec52 100644 --- a/tests/example_tests/test_dvs.py +++ b/tests/example_tests/test_dvs.py @@ -64,7 +64,8 @@ def test_dvs_data(tmpdir, pytestconfig: pytest.Config): launcher = DockerLauncher(data_directory=data_dir, use_dev=True) session = launcher.start() counter = 0 - while True and counter < 5: + success = False + while not success and counter < 5: try: cas_file = session.download_pyansys_example( "mixing_elbow.cas.h5", "pyfluent/mixing_elbow" @@ -72,10 +73,11 @@ def test_dvs_data(tmpdir, pytestconfig: pytest.Config): dat_file = session.download_pyansys_example( "mixing_elbow.dat.h5", "pyfluent/mixing_elbow" ) + success = True except Exception: counter += 1 time.sleep(60) - if counter == 5: + if counter == 5 and not success: raise RuntimeError("Couldn't download data from github") session.load_data(cas_file, result_file=dat_file) dvs = None diff --git a/tests/example_tests/test_libuserd.py b/tests/example_tests/test_libuserd.py index 78d7584e340..1bb3ace33d2 100644 --- a/tests/example_tests/test_libuserd.py +++ b/tests/example_tests/test_libuserd.py @@ -19,7 +19,8 @@ def test_libuserd_basic(tmpdir, pytestconfig: pytest.Config): _ = libuserd.ansys_release_number() _ = libuserd.ansys_release_string() counter = 0 - while True and counter < 5: + success = False + while not success and counter < 5: try: cas_file = libuserd.download_pyansys_example( "mixing_elbow.cas.h5", "pyfluent/mixing_elbow" @@ -27,10 +28,11 @@ def test_libuserd_basic(tmpdir, pytestconfig: pytest.Config): dat_file = libuserd.download_pyansys_example( "mixing_elbow.dat.h5", "pyfluent/mixing_elbow" ) + success = True except Exception: counter += 1 time.sleep(60) - if counter == 5: + if counter == 5 and not success: raise RuntimeError("Couldn't download data from github") r = libuserd.query_format(cas_file, dat_file) d = r[0].read_dataset(cas_file, dat_file)