From 319a3cdd19e3b217fef52bd2a975aa704853b976 Mon Sep 17 00:00:00 2001 From: vrane-tibco <158255115+vrane-tibco@users.noreply.github.com> Date: Wed, 3 Sep 2025 13:03:57 +0530 Subject: [PATCH 1/4] Update test_sbdf.py --- spotfire/test/test_sbdf.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/spotfire/test/test_sbdf.py b/spotfire/test/test_sbdf.py index 1158bb1..856be76 100644 --- a/spotfire/test/test_sbdf.py +++ b/spotfire/test/test_sbdf.py @@ -428,8 +428,11 @@ def test_tz_aware_datetime(self): df2 = self._roundtrip_dataframe(dataframe) for col in df2.columns: val = df2.at[0, col] - self.assertAlmostEqual(val, now, msg=f"df2[{col}] = {repr(val)}", - delta=datetime.timedelta(milliseconds=1)) # SBDF has millisecond resolution + self.assertLessEqual( + abs(val - now), + datetime.timedelta(milliseconds=1), + msg=f"df2[{col}] = {repr(val)}" + ) # SBDF has millisecond resolution def test_numpy_datetime_resolution(self): """Verify that different NumPy resolutions for datetime64 dtypes export properly.""" @@ -517,7 +520,7 @@ def _roundtrip_dataframe(dataframe: typing.Any) -> pd.DataFrame: sbdf.export_data(dataframe, f"{tempdir}/output.sbdf") return sbdf.import_data(f"{tempdir}/output.sbdf") - def _assert_dataframe_shape(self, dataframe: pd.DataFrame, rows: int, column_names: typing.List[str]) -> None: + def _assert_dataframe_shape(self, dataframe: pd.DataFrame, rows: int, column_names: list[str]) -> None: """Assert that a dataframe has a specific number of rows and the given column names.""" self.assertEqual(len(dataframe), rows, msg="number of rows") self.assertEqual(len(dataframe.columns), len(column_names), msg="number of columns") From 10d3ebf2fba3721f8b0464068ff4f0921d0cf152 Mon Sep 17 00:00:00 2001 From: vrane-tibco <158255115+vrane-tibco@users.noreply.github.com> Date: Wed, 3 Sep 2025 13:15:39 +0530 Subject: [PATCH 2/4] static analysis issues fix --- spotfire/test/test_sbdf.py | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/spotfire/test/test_sbdf.py b/spotfire/test/test_sbdf.py index 856be76..9e2ae68 100644 --- a/spotfire/test/test_sbdf.py +++ b/spotfire/test/test_sbdf.py @@ -428,11 +428,11 @@ def test_tz_aware_datetime(self): df2 = self._roundtrip_dataframe(dataframe) for col in df2.columns: val = df2.at[0, col] - self.assertLessEqual( - abs(val - now), - datetime.timedelta(milliseconds=1), - msg=f"df2[{col}] = {repr(val)}" - ) # SBDF has millisecond resolution + # Instead of self.assertAlmostEqual(val, now, delta=timedelta(...)) + if isinstance(val, (datetime.datetime, pd.Timestamp)): + self.assertLessEqual(abs(val - now), datetime.timedelta(milliseconds=1)) + else: + self.assertEqual(val, now) # SBDF has millisecond resolution def test_numpy_datetime_resolution(self): """Verify that different NumPy resolutions for datetime64 dtypes export properly.""" @@ -476,6 +476,10 @@ def test_image_matplot(self): self._assert_dataframe_shape(df2, 1, ['x']) image = df2.at[0, "x"] self._assert_is_png_image(image) + if isinstance(image, (bytes, bytearray)): + self._assert_is_png_image(image) + else: + self.fail(f"Expected PNG bytes, got {type(image)}: {image!r}") def test_image_seaborn(self): """Verify Seaborn grids export properly.""" @@ -485,7 +489,10 @@ def test_image_seaborn(self): df2 = self._roundtrip_dataframe(grid) self._assert_dataframe_shape(df2, 1, ['x']) image = df2.at[0, "x"] - self._assert_is_png_image(image) + if isinstance(image, (bytes, bytearray)): + self._assert_is_png_image(image) + else: + self.fail(f"Expected PNG bytes, got {type(image)}: {image!r}") def test_image_pil(self): """Verify PIL images export properly.""" @@ -493,7 +500,10 @@ def test_image_pil(self): df2 = self._roundtrip_dataframe(image) self._assert_dataframe_shape(df2, 1, ['x']) val = df2.at[0, "x"] - self._assert_is_png_image(val) + if isinstance(image, (bytes, bytearray)): + self._assert_is_png_image(image) + else: + self.fail(f"Expected PNG bytes, got {type(image)}: {image!r}") def test_export_import_unicode_path(self): """Test export and import with a Unicode file path.""" From 7794bed30b6f1b2191c271e3186afb055c1ea8b5 Mon Sep 17 00:00:00 2001 From: vrane-tibco <158255115+vrane-tibco@users.noreply.github.com> Date: Wed, 3 Sep 2025 13:28:25 +0530 Subject: [PATCH 3/4] Update test_sbdf.py --- spotfire/test/test_sbdf.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spotfire/test/test_sbdf.py b/spotfire/test/test_sbdf.py index 9e2ae68..6ac915a 100644 --- a/spotfire/test/test_sbdf.py +++ b/spotfire/test/test_sbdf.py @@ -500,10 +500,10 @@ def test_image_pil(self): df2 = self._roundtrip_dataframe(image) self._assert_dataframe_shape(df2, 1, ['x']) val = df2.at[0, "x"] - if isinstance(image, (bytes, bytearray)): - self._assert_is_png_image(image) + if isinstance(val, (bytes, bytearray)): + self._assert_is_png_image(val) else: - self.fail(f"Expected PNG bytes, got {type(image)}: {image!r}") + self.fail(f"Expected PNG bytes, got {type(val)}: {val!r}") def test_export_import_unicode_path(self): """Test export and import with a Unicode file path.""" From 1457c644a7c3773541eb6e0479582b49ddb2f85f Mon Sep 17 00:00:00 2001 From: vrane-tibco <158255115+vrane-tibco@users.noreply.github.com> Date: Wed, 3 Sep 2025 13:56:23 +0530 Subject: [PATCH 4/4] Update test_sbdf.py --- spotfire/test/test_sbdf.py | 1 - 1 file changed, 1 deletion(-) diff --git a/spotfire/test/test_sbdf.py b/spotfire/test/test_sbdf.py index 6ac915a..de89774 100644 --- a/spotfire/test/test_sbdf.py +++ b/spotfire/test/test_sbdf.py @@ -475,7 +475,6 @@ def test_image_matplot(self): df2 = self._roundtrip_dataframe(fig) self._assert_dataframe_shape(df2, 1, ['x']) image = df2.at[0, "x"] - self._assert_is_png_image(image) if isinstance(image, (bytes, bytearray)): self._assert_is_png_image(image) else: