def test_error_should_be_25_over_2(self): """Tests that the mean squared error between (0, 0) and (3, 4) is 12.5.""" self.assertEqual(comparator.distance(self.two_zeros, self.three_four), 12.5) self.assertEqual(comparator.distance(self.three_four, self.two_zeros), 12.5)
def test_error_should_be_one(self): """Tests that the mean squared error between (0, 0, 0, 0, 0) and (1, 1, 1, 1, 1) is 1.""" self.assertEqual(comparator.distance(self.five_zeros, self.int_ones), 1) self.assertEqual(comparator.distance(self.int_ones, self.five_zeros), 1) self.assertEqual(comparator.distance(self.five_zeros, self.complex_ones), 1) self.assertEqual(comparator.distance(self.complex_ones, self.five_zeros), 1)
def test_texts_are_begin_compared_correctly(): reference = "Lorem ipsum dolor" good = [ reference, reference.lower(), "Larem ipsum dalor", "Loremipsumdolor", "lorem ipsum dolor", ] bad = [ "lrem psum dolr", "ipsum lorem dolor", "dolor lorem ipsum", "dolor sit amet" ] assert is_acceptable(distance(good[0], reference)) assert is_acceptable(distance(good[1], reference)) assert is_acceptable(distance(good[2], reference)) assert is_acceptable(distance(good[3], reference)) assert is_acceptable(distance(good[4], reference)) assert is_acceptable(distance(bad[0], reference)) is False assert is_acceptable(distance(bad[1], reference)) is False assert is_acceptable(distance(bad[2], reference)) is False assert is_acceptable(distance(bad[3], reference)) is False