@@ -144,26 +144,22 @@ def test_old_call_convention(self):
144
144
145
145
def test_new_call_convention (self ):
146
146
"""This is how it should be called now."""
147
- warnings .simplefilter ("always" )
148
- with pytest .warns (None ) as warns :
147
+ # make sure no warnings are raised
148
+ with warnings .catch_warnings ():
149
+ warnings .simplefilter ("error" )
149
150
der = encode_bitstring (b"\xff " , 0 )
150
151
151
- # verify that new call convention doesn't raise Warnings
152
- self .assertEqual (len (warns ), 0 )
153
-
154
152
self .assertEqual (der , b"\x03 \x02 \x00 \xff " )
155
153
156
154
def test_implicit_unused_bits (self ):
157
155
"""
158
156
Writing bit string with already included the number of unused bits.
159
157
"""
160
- warnings .simplefilter ("always" )
161
- with pytest .warns (None ) as warns :
158
+ # make sure no warnings are raised
159
+ with warnings .catch_warnings ():
160
+ warnings .simplefilter ("error" )
162
161
der = encode_bitstring (b"\x00 \xff " , None )
163
162
164
- # verify that new call convention doesn't raise Warnings
165
- self .assertEqual (len (warns ), 0 )
166
-
167
163
self .assertEqual (der , b"\x03 \x02 \x00 \xff " )
168
164
169
165
def test_explicit_unused_bits (self ):
@@ -203,22 +199,20 @@ def test_old_call_convention(self):
203
199
self .assertEqual (rest , b"" )
204
200
205
201
def test_new_call_convention (self ):
206
- warnings .simplefilter ("always" )
207
- with pytest .warns (None ) as warns :
202
+ # make sure no warnings are raised
203
+ with warnings .catch_warnings ():
204
+ warnings .simplefilter ("error" )
208
205
bits , rest = remove_bitstring (b"\x03 \x02 \x00 \xff " , 0 )
209
206
210
- self .assertEqual (len (warns ), 0 )
211
-
212
207
self .assertEqual (bits , b"\xff " )
213
208
self .assertEqual (rest , b"" )
214
209
215
210
def test_implicit_unexpected_unused (self ):
216
- warnings .simplefilter ("always" )
217
- with pytest .warns (None ) as warns :
211
+ # make sure no warnings are raised
212
+ with warnings .catch_warnings ():
213
+ warnings .simplefilter ("error" )
218
214
bits , rest = remove_bitstring (b"\x03 \x02 \x00 \xff " , None )
219
215
220
- self .assertEqual (len (warns ), 0 )
221
-
222
216
self .assertEqual (bits , (b"\xff " , 0 ))
223
217
self .assertEqual (rest , b"" )
224
218
0 commit comments