def test_find_all_invalid_usage(self): """ Passing fewer or more than one query raises `ValueError`. """ enum = Enum('doc', []) self.assertThat( lambda: list(enum.find_all()), raises(ValueError)) self.assertThat( lambda: list(enum.find_all(foo=u'a', bar=u'b')), raises(ValueError))
def test_find_all(self): """ Finding all enumeration items by extra value gets an iterable of all matching items. Passing fewer or more than one query raises `ValueError`. """ values = enum_values_fixture() enum = Enum('doc', values) results = list(enum.find_all(frob=u'world')) self.assertThat( results, Equals([values[0], values[2]])) self.assertThat( enum.find_all(asdf=u'qwer'), After(list, Equals([])))