def test_as_pairs(self): """ Representing an enumeration as a list of pairs. """ values = enum_values_fixture() enum = Enum('doc', values) pairs = [(e.get('id', e.value), e.desc) for e in values] self.assertThat(enum.as_pairs(), Equals(pairs))
def test_hidden(self): """ Enumeration items that have their ``hidden`` flag set are not listed in the result of `Enum.as_pairs`. """ values = [ EnumItem(u'foo', u'Foo', hidden=True), EnumItem(u'bar', u'Bar'), EnumItem(u'pop', u'Pop')] enum = Enum('doc', values) enum.get(u'pop').hidden = True pairs = enum.as_pairs() self.assertThat(pairs, Equals([(u'bar', u'Bar')]))