Skip to content

Commit 427a34e

Browse files
Use warnings.catch_warnings instead of pytest.warns(None) in tests
1 parent 834c455 commit 427a34e

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

tests/test_pattern_properties.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import warnings
2+
13
import pytest
24

35

@@ -59,12 +61,11 @@ def test_pattern_with_escape_no_warnings(asserter):
5961
'bar': {}
6062
}
6163

62-
with pytest.warns(None) as record:
64+
with warnings.catch_warnings():
65+
warnings.simplefilter("error")
6366
asserter({
6467
'type': 'object',
6568
'patternProperties': {
6669
'\\w+': {'type': 'object'}
6770
}
6871
}, value, value)
69-
70-
assert len(record) == 0

tests/test_string.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import warnings
2+
13
import pytest
24

35
from fastjsonschema import JsonSchemaValueException
@@ -74,14 +76,13 @@ def test_pattern_with_space(asserter, pattern):
7476

7577

7678
def test_pattern_with_escape_no_warnings(asserter):
77-
with pytest.warns(None) as record:
79+
with warnings.catch_warnings():
80+
warnings.simplefilter("error")
7881
asserter({
7982
'type': 'string',
8083
'pattern': '\\s'
8184
}, ' ', ' ')
8285

83-
assert len(record) == 0
84-
8586

8687
exc = JsonSchemaValueException('data must be a valid regex', value='{data}', name='data', definition='{definition}', rule='format')
8788
@pytest.mark.parametrize('value, expected', [

0 commit comments

Comments
 (0)