From 1fd1864e86a6b36a61eef87f9cce50c527a1badb Mon Sep 17 00:00:00 2001 From: Gerda Shank Date: Wed, 13 Sep 2023 14:17:02 -0400 Subject: [PATCH 1/2] Fix test_numeric_values of the show test --- .../Under the Hood-20230913-141651.yaml | 6 +++++ tests/functional/show/test_show.py | 24 +++++++++---------- 2 files changed, 18 insertions(+), 12 deletions(-) create mode 100644 .changes/unreleased/Under the Hood-20230913-141651.yaml diff --git a/.changes/unreleased/Under the Hood-20230913-141651.yaml b/.changes/unreleased/Under the Hood-20230913-141651.yaml new file mode 100644 index 00000000000..6381d338787 --- /dev/null +++ b/.changes/unreleased/Under the Hood-20230913-141651.yaml @@ -0,0 +1,6 @@ +kind: Under the Hood +body: Fix test_numeric_values to look for more specific strings +time: 2023-09-13T14:16:51.453247-04:00 +custom: + Author: gshank + Issue: "8470" diff --git a/tests/functional/show/test_show.py b/tests/functional/show/test_show.py index 42bddb2ddee..44aef066fae 100644 --- a/tests/functional/show/test_show.py +++ b/tests/functional/show/test_show.py @@ -83,12 +83,12 @@ def test_numeric_values(self, project): ["show", "--select", "sample_number_model", "--output", "json"] ) assert "Previewing node 'sample_number_model'" not in log_output - assert "1.0" not in log_output - assert "1" in log_output - assert "3.0" in log_output - assert "4.3" in log_output - assert "5" in log_output - assert "5.0" not in log_output + assert '"float_to_int_field": 1.0' not in log_output + assert '"float_to_int_field": 1' in log_output + assert '"float_field": 3.0' in log_output + assert '"float_with_dec_field": 4.3' in log_output + assert '"int_field": 5' in log_output + assert '"int_field": 5.0' not in log_output class TestShowNumericNulls(ShowBase): @@ -98,12 +98,12 @@ def test_numeric_values_with_nulls(self, project): ["show", "--select", "sample_number_model_with_nulls", "--output", "json"] ) assert "Previewing node 'sample_number_model_with_nulls'" not in log_output - assert "1.0" not in log_output - assert "1" in log_output - assert "3.0" in log_output - assert "4.3" in log_output - assert "5" in log_output - assert "5.0" not in log_output + assert '"float_to_int_field": 1.0' not in log_output + assert '"float_to_int_field": 1' in log_output + assert '"float_field": 3.0' in log_output + assert '"float_with_dec_field": 4.3' in log_output + assert '"int_field": 5' in log_output + assert '"int_field": 5.0' not in log_output class TestShowInline(ShowBase): From 3d116b3448ef68ab596f10caa9c22736393b500a Mon Sep 17 00:00:00 2001 From: Gerda Shank Date: Wed, 13 Sep 2023 15:17:25 -0400 Subject: [PATCH 2/2] Remove escapes for json log string matching --- tests/functional/show/test_show.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/functional/show/test_show.py b/tests/functional/show/test_show.py index 44aef066fae..67bb8e645bd 100644 --- a/tests/functional/show/test_show.py +++ b/tests/functional/show/test_show.py @@ -82,6 +82,8 @@ def test_numeric_values(self, project): (_, log_output) = run_dbt_and_capture( ["show", "--select", "sample_number_model", "--output", "json"] ) + # json log output needs the escapes removed for string matching + log_output = log_output.replace("\\", "") assert "Previewing node 'sample_number_model'" not in log_output assert '"float_to_int_field": 1.0' not in log_output assert '"float_to_int_field": 1' in log_output @@ -97,6 +99,8 @@ def test_numeric_values_with_nulls(self, project): (_, log_output) = run_dbt_and_capture( ["show", "--select", "sample_number_model_with_nulls", "--output", "json"] ) + # json log output needs the escapes removed for string matching + log_output = log_output.replace("\\", "") assert "Previewing node 'sample_number_model_with_nulls'" not in log_output assert '"float_to_int_field": 1.0' not in log_output assert '"float_to_int_field": 1' in log_output