def __contains__(self, aspect): # Check if ``aspects`` language is supported. if self.languages is not None and isinstance(aspect, aspectbase): if aspect.language not in self.languages: return False for item in self: if issubaspect(aspect, item): return aspect not in self.exclude return False
def test_extract_aspects_from_section_with_exclude(self): section = Section('section') section.append(Setting('aspects', 'commitmessage')) section.append(Setting('excludes', 'TrailingPeriod')) section.language = Language['py 3.4'] aspects = extract_aspects_from_section(section) self.assertTrue(issubaspect(get_aspect('trailingperiod'), get_aspect('commitmessage'))) self.assertIsNone(aspects.get('trailingperiod'))
def test_extract_aspects_from_section_with_exclude(self): section = Section('section') section.append(Setting('aspects', 'commitmessage')) section.append(Setting('excludes', 'TrailingPeriod')) section.append(Setting('language', 'py 3.4')) aspects = extract_aspects_from_section(section) self.assertTrue( issubaspect(get_aspect('trailingperiod'), get_aspect('commitmessage'))) self.assertIsNone(aspects.get('trailingperiod'))
def test_issubaspect(self, RootAspect): @RootAspect.subaspect class SubAspect: """ Description """ assert issubaspect(SubAspect, RootAspect) assert not issubaspect(Root, RootAspect) assert issubaspect(RootAspect, RootAspect) with pytest.raises(TypeError) as exc: issubaspect('String', SubAspect) assert (str(exc.value) == "'String' is not an aspectclass or " 'an instance of an aspectclass') with pytest.raises(TypeError) as exc: issubaspect(RootAspect, str) assert (str(exc.value) == "<class 'str'> is not an aspectclass or " 'an instance of an aspectclass') assert issubaspect(SubAspect('Python'), RootAspect)
def __contains__(self, aspect): for item in self: if issubaspect(aspect, item): return aspect not in self.exclude return False
def __contains__(self, aspect): for item in self: if issubaspect(aspect, item): return True return False