Skip to content

Commit 1383114

Browse files
committed
Profiler: use assertAlmostEquals in test for float values, refine sorting.
1 parent 4ce22d0 commit 1383114

1 file changed

Lines changed: 11 additions & 8 deletions

File tree

tests/test_profiles.py

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -82,14 +82,17 @@ def test_StringColumnProfile(self):
8282
self.assertEqual(column_profile.approximateNumDistinctValues, 3)
8383
self.assertEqual(column_profile.typeCounts["String"], 3)
8484
self.assertEqual(column_profile.isDataTypeInferred, False)
85-
self.assertListEqual(
86-
sorted(column_profile.histogram),
87-
[
88-
DistributionValue("bar", 1, 1/3),
89-
DistributionValue("bazz", 1, 1/3),
90-
DistributionValue("foo", 1, 1/3),
91-
]
92-
)
85+
actual_histogram = sorted(column_profile.histogram, key=lambda x: x.value)
86+
self.assertEqual(len(actual_histogram), 3)
87+
expected_histogram = [
88+
DistributionValue("bar", 1, 1 / 3),
89+
DistributionValue("bazz", 1, 1 / 3),
90+
DistributionValue("foo", 1, 1 / 3),
91+
]
92+
for actual, expected in zip(actual_histogram, expected_histogram):
93+
self.assertEqual(actual.value, expected.value)
94+
self.assertEqual(actual.count, expected.count)
95+
self.assertAlmostEquals(actual.ratio, expected.ratio)
9396

9497

9598
if __name__ == "__main__":

0 commit comments

Comments
 (0)