Skip to content

Commit dbe114c

Browse files
committed
Add docstring with tests for EntryPoint.matches. Ref #373.
1 parent ee566d0 commit dbe114c

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

importlib_metadata/__init__.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,25 @@ def __iter__(self):
235235
return iter((self.name, self))
236236

237237
def matches(self, **params):
238+
"""
239+
EntryPoint matches the given parameters.
240+
241+
>>> ep = EntryPoint(group='foo', name='bar', value='bing:bong [extra1, extra2]')
242+
>>> ep.matches(group='foo')
243+
True
244+
>>> ep.matches(name='bar', value='bing:bong [extra1, extra2]')
245+
True
246+
>>> ep.matches(group='foo', name='other')
247+
False
248+
>>> ep.matches()
249+
True
250+
>>> ep.matches(extras=['extra1', 'extra2'])
251+
True
252+
>>> ep.matches(module='bing')
253+
True
254+
>>> ep.matches(attr='bong')
255+
True
256+
"""
238257
attrs = (getattr(self, param) for param in params)
239258
return all(map(operator.eq, params.values(), attrs))
240259

0 commit comments

Comments
 (0)