(self, request: FixtureRequest)
| 146 | name=f"_unittest_{setup_name}_fixture_{obj.__qualname__}", |
| 147 | ) |
| 148 | def fixture(self, request: FixtureRequest) -> Generator[None, None, None]: |
| 149 | if _is_skipped(self): |
| 150 | reason = self.__unittest_skip_why__ |
| 151 | raise pytest.skip.Exception(reason, _use_item_location=True) |
| 152 | if setup is not None: |
| 153 | try: |
| 154 | if pass_self: |
| 155 | setup(self, request.function) |
| 156 | else: |
| 157 | setup() |
| 158 | # unittest does not call the cleanup function for every BaseException, so we |
| 159 | # follow this here. |
| 160 | except Exception: |
| 161 | if pass_self: |
| 162 | cleanup(self) |
| 163 | else: |
| 164 | cleanup() |
| 165 | |
| 166 | raise |
| 167 | yield |
| 168 | try: |
| 169 | if teardown is not None: |
| 170 | if pass_self: |
| 171 | teardown(self, request.function) |
| 172 | else: |
| 173 | teardown() |
| 174 | finally: |
| 175 | if pass_self: |
| 176 | cleanup(self) |
| 177 | else: |
| 178 | cleanup() |
| 179 | |
| 180 | return fixture |
| 181 |
nothing calls this directly
no test coverage detected