MCPcopy Create free account
hub / github.com/libgit2/pygit2 / assertRaisesWithArg

Function assertRaisesWithArg

test/utils.py:145–166  ·  view source on GitHub ↗
(
    exc_class: type[Exception],
    arg: object,
    func: Callable[P, T],
    *args: P.args,
    **kwargs: P.kwargs,
)

Source from the content-addressed store, hash-verified

143
144
145def assertRaisesWithArg(
146 exc_class: type[Exception],
147 arg: object,
148 func: Callable[P, T],
149 *args: P.args,
150 **kwargs: P.kwargs,
151) -> None:
152 with pytest.raises(exc_class) as excinfo:
153 func(*args, **kwargs)
154 assert excinfo.value.args == (arg,)
155
156 # Explicitly clear the Exception Info. Citing
157 # https://docs.pytest.org/en/latest/reference.html#pytest-raises:
158 #
159 # Clearing those references breaks a reference cycle
160 # (ExceptionInfo –> caught exception –> frame stack raising the exception
161 # –> current frame stack –> local variables –> ExceptionInfo) which makes
162 # Python keep all objects referenced from that cycle (including all local
163 # variables in the current frame) alive until the next cyclic garbage
164 # collection run. See the official Python try statement documentation for
165 # more detailed information.
166 del excinfo

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…