Skip to content

Commit

Permalink
Use warnings.catch_warnings instead of pytest.warns(None) in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
edgarrmondragon committed Nov 15, 2023
1 parent 834c455 commit 427a34e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
7 changes: 4 additions & 3 deletions tests/test_pattern_properties.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import warnings

import pytest


Expand Down Expand Up @@ -59,12 +61,11 @@ def test_pattern_with_escape_no_warnings(asserter):
'bar': {}
}

with pytest.warns(None) as record:
with warnings.catch_warnings():
warnings.simplefilter("error")
asserter({
'type': 'object',
'patternProperties': {
'\\w+': {'type': 'object'}
}
}, value, value)

assert len(record) == 0
7 changes: 4 additions & 3 deletions tests/test_string.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import warnings

import pytest

from fastjsonschema import JsonSchemaValueException
Expand Down Expand Up @@ -74,14 +76,13 @@ def test_pattern_with_space(asserter, pattern):


def test_pattern_with_escape_no_warnings(asserter):
with pytest.warns(None) as record:
with warnings.catch_warnings():
warnings.simplefilter("error")
asserter({
'type': 'string',
'pattern': '\\s'
}, ' ', ' ')

assert len(record) == 0


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

0 comments on commit 427a34e

Please sign in to comment.