Open jdufresne opened 5 years ago
Example input:
class MyTest(unittest.TestCase): def test_thing(self): self.my_custom_assert(self.assertRaises(IOError, my_func))
Output
@@ -1,3 +1,5 @@ +import pytest class MyTest(unittest.TestCase): def test_thing(self): - self.my_custom_assert(self.assertRaises(IOError, my_func)) + self.my_custom_assert(with pytest.raises(IOError): + my_func())
There is now a with statement as the first argument passed to my_custom_assert. pytest.raises also supports an expression syntax, so perhaps that should be used here as well.
with
my_custom_assert
pytest.raises
This came up in a real life project:
https://github.com/python-pillow/Pillow/blob/7bf5246b93cc89cfb9d6cca78c4719a943b10585/Tests/test_file_webp.py#L20
This should be easy to fiy by adding here a test whether the current nodes parent node is an expression - or something like this.
We's apprechiae a pull-request. Please mind adding a test-case, too. Thanks.
Example input:
Output
There is now a
with
statement as the first argument passed tomy_custom_assert
.pytest.raises
also supports an expression syntax, so perhaps that should be used here as well.This came up in a real life project:
https://github.com/python-pillow/Pillow/blob/7bf5246b93cc89cfb9d6cca78c4719a943b10585/Tests/test_file_webp.py#L20