Skip to content

Commit 35910b4

Browse files
Apply ruff/flake8-pytest-style rule PT027
PT027 Use `pytest.raises` instead of unittest-style `assertRaises`
1 parent c93afb1 commit 35910b4

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

tests/test_dicttoxml.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,14 @@ def lazy_obj():
6363
assert unparse(lazy_obj()) == unparse(parse(unparse(lazy_obj())))
6464

6565
def test_no_root(self):
66-
self.assertRaises(ValueError, unparse, {})
66+
with pytest.raises(ValueError):
67+
unparse({})
6768

6869
def test_multiple_roots(self):
69-
self.assertRaises(ValueError, unparse, {'a': '1', 'b': '2'})
70-
self.assertRaises(ValueError, unparse, {'a': ['1', '2', '3']})
70+
with pytest.raises(ValueError):
71+
unparse({'a': '1', 'b': '2'})
72+
with pytest.raises(ValueError):
73+
unparse({'a': ['1', '2', '3']})
7174

7275
def test_no_root_nofulldoc(self):
7376
assert unparse({}, full_document=False) == ''

tests/test_xmltodict.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,9 @@ def cb(path, item):
9292

9393
def test_streaming_interrupt(self):
9494
cb = lambda path, item: False
95-
self.assertRaises(ParsingInterrupted,
96-
parse, '<a>x</a>',
97-
item_depth=1, item_callback=cb)
95+
96+
with pytest.raises(ParsingInterrupted):
97+
parse('<a>x</a>', item_depth=1, item_callback=cb)
9898

9999
def test_streaming_generator(self):
100100
def cb(path, item):

0 commit comments

Comments
 (0)