@@ -83,9 +83,8 @@ def __eq__(self, other):
8383 b = _strip_and_dedent (other ).splitlines ()
8484 if a == b :
8585 return True
86- else :
87- self .explanation = _make_explanation (a , b )
88- return False
86+ self .explanation = _make_explanation (a , b )
87+ return False
8988
9089
9190class Unordered (Output ):
@@ -96,9 +95,8 @@ def __eq__(self, other):
9695 b = _split_and_sort (other )
9796 if a == b :
9897 return True
99- else :
100- self .explanation = _make_explanation (a , b )
101- return False
98+ self .explanation = _make_explanation (a , b )
99+ return False
102100
103101
104102class Capture :
@@ -119,9 +117,8 @@ def __eq__(self, other):
119117 b = other
120118 if a == b :
121119 return True
122- else :
123- self .explanation = a .explanation
124- return False
120+ self .explanation = a .explanation
121+ return False
125122
126123 def __str__ (self ):
127124 return self .out
@@ -138,7 +135,7 @@ def stderr(self):
138135 return Output (self .err )
139136
140137
141- @pytest .fixture
138+ @pytest .fixture ()
142139def capture (capsys ):
143140 """Extended `capsys` with context manager and custom equality operators"""
144141 return Capture (capsys )
@@ -159,25 +156,22 @@ def __eq__(self, other):
159156 b = _strip_and_dedent (other )
160157 if a == b :
161158 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
165161
166162
167163def _sanitize_general (s ):
168164 s = s .strip ()
169165 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 )
172167
173168
174169def _sanitize_docstring (thing ):
175170 s = thing .__doc__
176- s = _sanitize_general (s )
177- return s
171+ return _sanitize_general (s )
178172
179173
180- @pytest .fixture
174+ @pytest .fixture ()
181175def doc ():
182176 """Sanitize docstrings and add custom failure explanation"""
183177 return SanitizedString (_sanitize_docstring )
@@ -186,30 +180,20 @@ def doc():
186180def _sanitize_message (thing ):
187181 s = str (thing )
188182 s = _sanitize_general (s )
189- s = _hexadecimal .sub ("0" , s )
190- return s
183+ return _hexadecimal .sub ("0" , s )
191184
192185
193- @pytest .fixture
186+ @pytest .fixture ()
194187def msg ():
195188 """Sanitize messages and add custom failure explanation"""
196189 return SanitizedString (_sanitize_message )
197190
198191
199- # noinspection PyUnusedLocal
200- def pytest_assertrepr_compare (op , left , right ):
192+ def pytest_assertrepr_compare (op , left , right ): # noqa: ARG001
201193 """Hook to insert custom failure explanation"""
202194 if hasattr (left , "explanation" ):
203195 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
213197
214198
215199def gc_collect ():
@@ -220,7 +204,7 @@ def gc_collect():
220204
221205
222206def pytest_configure ():
223- pytest .suppress = suppress
207+ pytest .suppress = contextlib . suppress
224208 pytest .gc_collect = gc_collect
225209
226210
0 commit comments