From 1d7f55ed8e5557f5c17d99769dc43498a056603a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A5vard=20Berland?= Date: Tue, 17 Dec 2024 10:06:41 +0100 Subject: [PATCH] Fix more f-strings These are manually crafted, not feasible by use of ruff --- .../mocked_test_case/jobs/oil_prod_rate_mock.py | 2 +- tests/everest/test_templating.py | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/everest/test_data/mocked_test_case/jobs/oil_prod_rate_mock.py b/tests/everest/test_data/mocked_test_case/jobs/oil_prod_rate_mock.py index c216c11672a..122b62343fd 100755 --- a/tests/everest/test_data/mocked_test_case/jobs/oil_prod_rate_mock.py +++ b/tests/everest/test_data/mocked_test_case/jobs/oil_prod_rate_mock.py @@ -22,7 +22,7 @@ def main(argv): for i in range(0, len(times)): val = sum.get("FOPR")[i] - save_return_value(val, "oil_prod_rate_%03d" % i) + save_return_value(val, f"oil_prod_rate_{i:03d}") with open("OIL_PROD_RATE_OK", "w", encoding="utf-8") as f: f.write("Everything went fine here!") diff --git a/tests/everest/test_templating.py b/tests/everest/test_templating.py index 5d337656f4e..6a551897003 100644 --- a/tests/everest/test_templating.py +++ b/tests/everest/test_templating.py @@ -19,7 +19,7 @@ def test_render_invalid(copy_template_test_data_to_tmp): render = everest.jobs.templating.render - prod_wells = {"PROD%d" % idx: 0.3 * idx for idx in range(4)} + prod_wells = {f"PROD{idx:d}": 0.3 * idx for idx in range(4)} prod_in = "well_drill_prod.json" with open(prod_in, "w", encoding="utf-8") as fout: json.dump(prod_wells, fout) @@ -45,8 +45,8 @@ def test_render_invalid(copy_template_test_data_to_tmp): def test_render(copy_template_test_data_to_tmp): render = everest.jobs.templating.render - wells = {"PROD%d" % idx: 0.2 * idx for idx in range(1, 5)} - wells.update({"INJ%d" % idx: 1 - 0.2 * idx for idx in range(1, 5)}) + wells = {f"PROD{idx:d}": 0.2 * idx for idx in range(1, 5)} + wells.update({f"INJ{idx:d}": 1 - 0.2 * idx for idx in range(1, 5)}) wells_in = "well_drill.json" with open(wells_in, "w", encoding="utf-8") as fout: json.dump(wells, fout) @@ -75,12 +75,12 @@ def test_render(copy_template_test_data_to_tmp): def test_render_multiple_input(copy_template_test_data_to_tmp): render = everest.jobs.templating.render - wells_north = {"PROD%d" % idx: 0.2 * idx for idx in range(1, 5)} + wells_north = {f"PROD{idx:d}": 0.2 * idx for idx in range(1, 5)} wells_north_in = "well_drill_north.json" with open(wells_north_in, "w", encoding="utf-8") as fout: json.dump(wells_north, fout) - wells_south = {"PROD%d" % idx: 1 - 0.2 * idx for idx in range(1, 5)} + wells_south = {f"PROD{idx:d}": 1 - 0.2 * idx for idx in range(1, 5)} wells_south_in = "well_drill_south.json" with open(wells_south_in, "w", encoding="utf-8") as fout: json.dump(wells_south, fout) @@ -98,12 +98,12 @@ def test_render_executable(copy_template_test_data_to_tmp): assert os.access(everest.jobs.render, os.X_OK) # Dump input - wells_north = {"PROD%d" % idx: 0.2 * idx for idx in range(1, 5)} + wells_north = {f"PROD{idx:d}": 0.2 * idx for idx in range(1, 5)} wells_north_in = "well_drill_north.json" with open(wells_north_in, "w", encoding="utf-8") as fout: json.dump(wells_north, fout) - wells_south = {"PROD%d" % idx: 1 - 0.2 * idx for idx in range(1, 5)} + wells_south = {f"PROD{idx:d}": 1 - 0.2 * idx for idx in range(1, 5)} wells_south_in = "well_drill_south.json" with open(wells_south_in, "w", encoding="utf-8") as fout: json.dump(wells_south, fout)