Пример #1
0
class TestComparator(unittest.TestCase):

    def setUp(self):
        from webcompare import Comparator
        self.comparator = Comparator()

    def test___init__perfect(self):
        self.assertRaises(RuntimeError, self.comparator.compare, "orig", "targ")

    def test_collapse_whitespace(self):
        self.assertEquals(self.comparator.collapse_whitespace("  foo   bar  "), "foo bar")

    def test_fuzziness(self):
        self.assertEquals(self.comparator.fuzziness("foo", "foo"), 100)
        self.assertEquals(self.comparator.fuzziness("foo", "foo "), 100)
        self.assertEquals(self.comparator.fuzziness("foo", "Foo"), 100)
        self.assertEquals(self.comparator.fuzziness("foo", "fool"), 85)

    def test_unfraction(self):
        self.assertEquals(self.comparator.unfraction(1.0), 100)
        self.assertEquals(self.comparator.unfraction(1), 100)
        self.assertEquals(self.comparator.unfraction(0.0), 0)
        self.assertEquals(self.comparator.unfraction(0), 0)
        self.assertEquals(self.comparator.unfraction(1.0/3.0), 33)
Пример #2
0
 def setUp(self):
     from webcompare import Comparator
     self.comparator = Comparator()