MCPcopy Index your code
hub / github.com/python/cpython / passes

Method passes

Lib/importlib/metadata/_context.py:99–118  ·  view source on GitHub ↗

Wrap func and replace the result with the truth value of the trap (True if no exception). First, give the decorator an alias to support Python 3.8 Syntax. >>> passes = ExceptionTrap(ValueError).passes Now decorate a function that always fails.

(self, func)

Source from the content-addressed store, hash-verified

97 return wrapper
98
99 def passes(self, func):
100 """
101 Wrap func and replace the result with the truth
102 value of the trap (True if no exception).
103
104 First, give the decorator an alias to support Python 3.8
105 Syntax.
106
107 >>> passes = ExceptionTrap(ValueError).passes
108
109 Now decorate a function that always fails.
110
111 >>> @passes
112 ... def fail():
113 ... raise ValueError('failed')
114
115 >>> fail()
116 False
117 """
118 return self.raises(func, _test=operator.not_)

Callers 1

_prefer_validMethod · 0.80

Calls 1

raisesMethod · 0.95

Tested by

no test coverage detected