Example #1
0
def test_flag_packing():
    random.seed(8025816322119661921)  # ayy lmao
    nflags = len(Flags.__members__)
    cases = chain(
        random.sample(list(product((True, False), repeat=nflags)), 1000),
        [[True] * nflags],
        [[False] * nflags],
    )
    for flagvals in cases:
        flags = dict(zip(Flags.__members__.keys(), flagvals))
        assert Flags.unpack(Flags.pack(**flags)) == flags
Example #2
0
def test_flag_unpack_too_big():
    assert all(Flags.unpack(Flags.max).values())
    with pytest.raises(ValueError):
        Flags.unpack(Flags.max + 1)