@@ -83,9 +83,8 @@ def __eq__(self, other):
83
83
b = _strip_and_dedent (other ).splitlines ()
84
84
if a == b :
85
85
return True
86
- else :
87
- self .explanation = _make_explanation (a , b )
88
- return False
86
+ self .explanation = _make_explanation (a , b )
87
+ return False
89
88
90
89
91
90
class Unordered (Output ):
@@ -96,9 +95,8 @@ def __eq__(self, other):
96
95
b = _split_and_sort (other )
97
96
if a == b :
98
97
return True
99
- else :
100
- self .explanation = _make_explanation (a , b )
101
- return False
98
+ self .explanation = _make_explanation (a , b )
99
+ return False
102
100
103
101
104
102
class Capture :
@@ -119,9 +117,8 @@ def __eq__(self, other):
119
117
b = other
120
118
if a == b :
121
119
return True
122
- else :
123
- self .explanation = a .explanation
124
- return False
120
+ self .explanation = a .explanation
121
+ return False
125
122
126
123
def __str__ (self ):
127
124
return self .out
@@ -138,7 +135,7 @@ def stderr(self):
138
135
return Output (self .err )
139
136
140
137
141
- @pytest .fixture
138
+ @pytest .fixture ()
142
139
def capture (capsys ):
143
140
"""Extended `capsys` with context manager and custom equality operators"""
144
141
return Capture (capsys )
@@ -159,25 +156,22 @@ def __eq__(self, other):
159
156
b = _strip_and_dedent (other )
160
157
if a == b :
161
158
return True
162
- else :
163
- self .explanation = _make_explanation (a .splitlines (), b .splitlines ())
164
- return False
159
+ self .explanation = _make_explanation (a .splitlines (), b .splitlines ())
160
+ return False
165
161
166
162
167
163
def _sanitize_general (s ):
168
164
s = s .strip ()
169
165
s = s .replace ("pybind11_tests." , "m." )
170
- s = _long_marker .sub (r"\1" , s )
171
- return s
166
+ return _long_marker .sub (r"\1" , s )
172
167
173
168
174
169
def _sanitize_docstring (thing ):
175
170
s = thing .__doc__
176
- s = _sanitize_general (s )
177
- return s
171
+ return _sanitize_general (s )
178
172
179
173
180
- @pytest .fixture
174
+ @pytest .fixture ()
181
175
def doc ():
182
176
"""Sanitize docstrings and add custom failure explanation"""
183
177
return SanitizedString (_sanitize_docstring )
@@ -186,30 +180,20 @@ def doc():
186
180
def _sanitize_message (thing ):
187
181
s = str (thing )
188
182
s = _sanitize_general (s )
189
- s = _hexadecimal .sub ("0" , s )
190
- return s
183
+ return _hexadecimal .sub ("0" , s )
191
184
192
185
193
- @pytest .fixture
186
+ @pytest .fixture ()
194
187
def msg ():
195
188
"""Sanitize messages and add custom failure explanation"""
196
189
return SanitizedString (_sanitize_message )
197
190
198
191
199
- # noinspection PyUnusedLocal
200
- def pytest_assertrepr_compare (op , left , right ):
192
+ def pytest_assertrepr_compare (op , left , right ): # noqa: ARG001
201
193
"""Hook to insert custom failure explanation"""
202
194
if hasattr (left , "explanation" ):
203
195
return left .explanation
204
-
205
-
206
- @contextlib .contextmanager
207
- def suppress (exception ):
208
- """Suppress the desired exception"""
209
- try :
210
- yield
211
- except exception :
212
- pass
196
+ return None
213
197
214
198
215
199
def gc_collect ():
@@ -220,7 +204,7 @@ def gc_collect():
220
204
221
205
222
206
def pytest_configure ():
223
- pytest .suppress = suppress
207
+ pytest .suppress = contextlib . suppress
224
208
pytest .gc_collect = gc_collect
225
209
226
210
0 commit comments