def test_unicode_categories(self): self.assertEqual(sum(len(v) for k, v in UNICODE_CATEGORIES.items() if len(k) > 1), sys.maxunicode + 1) self.assertEqual(min([min(s) for s in UNICODE_CATEGORIES.values()]), 0) self.assertEqual(max([max(s) for s in UNICODE_CATEGORIES.values()]), sys.maxunicode) base_sets = [set(v) for k, v in UNICODE_CATEGORIES.items() if len(k) > 1] self.assertFalse(any(s.intersection(t) for s in base_sets for t in base_sets if s != t))
def test_conjunctions(self): n_code_points = sum( len(v) for k, v in UNICODE_CATEGORIES.items() if len(k) > 1) self.assertTrue( n_code_points == sys.maxunicode + 1, "The Unicode categories have a wrong number of elements: %d (!= %d) " % (n_code_points, sys.maxunicode + 1))
def test_disjunction(self): base_sets = [v for k, v in UNICODE_CATEGORIES.items() if len(k) > 1] self.assertFalse( any([ s.intersection(t) for s in base_sets for t in base_sets if s != t ]), "The Unicode categories are not mutually disjoined.")
def test_conjunctions(self): n_code_points = len( set.union( *[v for k, v in UNICODE_CATEGORIES.items() if len(k) > 1])) self.assertTrue( n_code_points == maxunicode + 1, "The Unicode categories have a wrong number of elements: %d (!= %d) " % (n_code_points, maxunicode + 1))
def test_min_value(self): min_code_point = min([min(s) for s in UNICODE_CATEGORIES.values()]) self.assertTrue( min_code_point >= 0, "The Unicode categories have negative code points: %d" % min_code_point)
def test_max_value(self): max_code_point = max([max(s) for s in UNICODE_CATEGORIES.values()]) self.assertTrue( max_code_point <= sys.maxunicode, "The Unicode categories have a code point greater than %d: %d" % (sys.maxunicode, max_code_point))