Skip to content

Commit

Permalink
Apply ruff/flake8-pytest-style rule PT027
Browse files Browse the repository at this point in the history
PT027 Use `pytest.raises` instead of unittest-style `assertRaises`
  • Loading branch information
DimitriPapadopoulos committed Oct 8, 2024
1 parent c93afb1 commit 35910b4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
9 changes: 6 additions & 3 deletions tests/test_dicttoxml.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,14 @@ def lazy_obj():
assert unparse(lazy_obj()) == unparse(parse(unparse(lazy_obj())))

def test_no_root(self):
self.assertRaises(ValueError, unparse, {})
with pytest.raises(ValueError):
unparse({})

def test_multiple_roots(self):
self.assertRaises(ValueError, unparse, {'a': '1', 'b': '2'})
self.assertRaises(ValueError, unparse, {'a': ['1', '2', '3']})
with pytest.raises(ValueError):
unparse({'a': '1', 'b': '2'})
with pytest.raises(ValueError):
unparse({'a': ['1', '2', '3']})

def test_no_root_nofulldoc(self):
assert unparse({}, full_document=False) == ''
Expand Down
6 changes: 3 additions & 3 deletions tests/test_xmltodict.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,9 +92,9 @@ def cb(path, item):

def test_streaming_interrupt(self):
cb = lambda path, item: False
self.assertRaises(ParsingInterrupted,
parse, '<a>x</a>',
item_depth=1, item_callback=cb)

with pytest.raises(ParsingInterrupted):
parse('<a>x</a>', item_depth=1, item_callback=cb)

def test_streaming_generator(self):
def cb(path, item):
Expand Down

0 comments on commit 35910b4

Please sign in to comment.