(self)
| 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 |
nothing calls this directly
no test coverage detected