MCPcopy Index your code
hub / github.com/ipython/ipython / setup

Method setup

IPython/testing/plugin/pytest_ipdoctest.py:308–331  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

306 return super().from_parent(name=name, parent=parent, runner=runner, dtest=dtest)
307
308 def setup(self) -> None:
309 if self.dtest is not None:
310 self.fixture_request = _setup_fixtures(self)
311 globs = dict(getfixture=self.fixture_request.getfixturevalue)
312 for name, value in self.fixture_request.getfixturevalue(
313 "ipdoctest_namespace"
314 ).items():
315 globs[name] = value
316 self.dtest.globs.update(globs)
317
318 from .ipdoctest import IPExample
319
320 if isinstance(self.dtest.examples[0], IPExample):
321 # for IPython examples *only*, we swap the globals with the ipython
322 # namespace, after updating it with the globals (which doctest
323 # fills with the necessary info from the module being tested).
324 self._user_ns_orig = {}
325 self._user_ns_orig.update(_ip.user_ns)
326 _ip.user_ns.update(self.dtest.globs)
327 # We must remove the _ key in the namespace, so that Python's
328 # doctest code sets it naturally
329 _ip.user_ns.pop("_", None)
330 _ip.user_ns["__builtins__"] = builtins
331 self.dtest.globs = _ip.user_ns
332
333 def teardown(self) -> None:
334 from .ipdoctest import IPExample

Callers

nothing calls this directly

Calls 3

_setup_fixturesFunction · 0.85
popMethod · 0.80
updateMethod · 0.45

Tested by

no test coverage detected