Skip to content

Commit d1cd887

Browse files
committed
Profiler: use assertAlmostEquals in test for float values, refine sorting.
1 parent 1d0fb21 commit d1cd887

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
@@ -86,14 +86,17 @@ def test_StringColumnProfile(self):
8686
self.assertEqual(column_profile.approximateNumDistinctValues, 3)
8787
self.assertEqual(column_profile.typeCounts["String"], 3)
8888
self.assertEqual(column_profile.isDataTypeInferred, False)
89-
self.assertListEqual(
90-
sorted(column_profile.histogram),
91-
[
92-
DistributionValue("bar", 1, 1/3),
93-
DistributionValue("bazz", 1, 1/3),
94-
DistributionValue("foo", 1, 1/3),
95-
]
96-
)
89+
actual_histogram = sorted(column_profile.histogram, key=lambda x: x.value)
90+
self.assertEqual(len(actual_histogram), 3)
91+
expected_histogram = [
92+
DistributionValue("bar", 1, 1 / 3),
93+
DistributionValue("bazz", 1, 1 / 3),
94+
DistributionValue("foo", 1, 1 / 3),
95+
]
96+
for actual, expected in zip(actual_histogram, expected_histogram):
97+
self.assertEqual(actual.value, expected.value)
98+
self.assertEqual(actual.count, expected.count)
99+
self.assertAlmostEquals(actual.ratio, expected.ratio)
97100

98101

99102
if __name__ == "__main__":

0 commit comments

Comments
 (0)