|
4 | 4 | from __future__ import annotations
|
5 | 5 |
|
6 | 6 | from collections.abc import Iterable, Mapping
|
| 7 | +from contextlib import suppress |
7 | 8 | from functools import partial
|
8 | 9 | from pathlib import Path
|
9 | 10 | from typing import TYPE_CHECKING, Any
|
@@ -131,13 +132,11 @@ def to_unittest_testcase(self, *groups, **kwargs):
|
131 | 132 | }
|
132 | 133 | cls = type(name, (unittest.TestCase,), methods)
|
133 | 134 |
|
134 |
| - try: |
| 135 | + # We're doing crazy things, so if they go wrong, like a function |
| 136 | + # behaving differently on some other interpreter, just make them |
| 137 | + # not happen. |
| 138 | + with suppress(Exception): |
135 | 139 | cls.__module__ = _someone_save_us_the_module_of_the_caller()
|
136 |
| - except Exception: # pragma: no cover |
137 |
| - # We're doing crazy things, so if they go wrong, like a function |
138 |
| - # behaving differently on some other interpreter, just make them |
139 |
| - # not happen. |
140 |
| - pass |
141 | 140 |
|
142 | 141 | return cls
|
143 | 142 |
|
@@ -255,10 +254,8 @@ def validate(self, Validator, **kwargs):
|
255 | 254 | validator.validate(instance=self.data)
|
256 | 255 |
|
257 | 256 | def validate_ignoring_errors(self, Validator): # pragma: no cover
|
258 |
| - try: |
| 257 | + with suppress(jsonschema.ValidationError): |
259 | 258 | self.validate(Validator=Validator)
|
260 |
| - except jsonschema.ValidationError: |
261 |
| - pass |
262 | 259 |
|
263 | 260 |
|
264 | 261 | def _someone_save_us_the_module_of_the_caller():
|
|
0 commit comments