def test_len(): c = Categories.from_string('{a|1,2,3}') assert len(c) == 4 assert len(c) == len(list(c)) c = Categories.from_string('{a|1,2,3}x{b|4,5,6}') assert len(c) == 16 c = Categories.from_string('{a|1,2,3}x{b|4,5,6*}') assert len(c) == 12 c = Categories.from_string('{a|1,2,3}x{b|*4,5,6*}') assert len(c) == 8 c = Categories.from_string('{a|1,2,3*}x{b|*4,5,6*}') assert len(c) == 6 c = Categories.from_string('{a|*1,2,3*}x{b|*4,5,6*}') assert len(c) == 4
def test_from_string(): for s in GOOD: Categories.from_string(s) for s in BAD: assert_raises(SyntaxError, Categories.from_string, s)