Esempio n. 1
0
    def test_add(self):
        flags = Flags([Flag("VALID_FLAG", 0x00)])
        assert not flags

        flags.add("VALID_FLAG")
        flags.add("VALID_FLAG")
        assert "VALID_FLAG" in flags
        assert list(flags) == ["VALID_FLAG"]
        assert len(flags) == 1
Esempio n. 2
0
    def test_add(self):
        flags = Flags([Flag("VALID_FLAG", 0x00)])
        assert not flags

        flags.add("VALID_FLAG")
        flags.add("VALID_FLAG")
        assert "VALID_FLAG" in flags
        assert list(flags) == ["VALID_FLAG"]
        assert len(flags) == 1
Esempio n. 3
0
    def test_remove(self):
        flags = Flags([Flag("VALID_FLAG", 0x00)])
        flags.add("VALID_FLAG")

        flags.discard("VALID_FLAG")
        assert "VALID_FLAG" not in flags
        assert list(flags) == []
        assert len(flags) == 0

        # discarding elements not in the set should not throw an exception
        flags.discard("END_STREAM")
Esempio n. 4
0
 def test_repr(self):
     flags = Flags([Flag("VALID_FLAG", 0x00), Flag("OTHER_FLAG", 0x01)])
     assert repr(flags) == "[]"
     flags.add("VALID_FLAG")
     assert repr(flags) == "['VALID_FLAG']"
     flags.add("OTHER_FLAG")
     assert repr(flags) == "['OTHER_FLAG', 'VALID_FLAG']"
Esempio n. 5
0
    def test_remove(self):
        flags = Flags([Flag("VALID_FLAG", 0x00)])
        flags.add("VALID_FLAG")

        flags.discard("VALID_FLAG")
        assert "VALID_FLAG" not in flags
        assert list(flags) == []
        assert len(flags) == 0

        # discarding elements not in the set should not throw an exception
        flags.discard("END_STREAM")
Esempio n. 6
0
 def test_validation(self):
     flags = Flags([Flag("VALID_FLAG", 0x00)])
     flags.add("VALID_FLAG")
     with pytest.raises(ValueError):
         flags.add("INVALID_FLAG")
Esempio n. 7
0
 def test_validation(self):
     flags = Flags([Flag("VALID_FLAG", 0x00)])
     flags.add("VALID_FLAG")
     with pytest.raises(ValueError):
         flags.add("INVALID_FLAG")