Closed boralyl closed 6 years ago
When running the following to convert asserts:
unittest2pytest -f self_assert test/test_foo.py
I consistently get the following output with the below test:
def test_foo(self): - with self.assertRaisesRegexp(ValueError, 'Invalid'): + with pytest.raises(ValueError) as excinfo: raise ValueError('Invalid') + assert re.search(pattern, excinfo.value)
Notice the variable pattern which isn't defined anywhere. This is with unittest2pytest==0.3
pattern
Also, it would be nicer if it didn't use re.search and just use the match kwarg to raises. e.g.
re.search
def test_foo(self): - with self.assertRaisesRegexp(ValueError, 'Invalid'): + with pytest.raises(ValueError, match='Invalid'): raise ValueError('Invalid')
Definitely, thanks for the report. We would appreciate a PR if you have the time, otherwise hope someone can tackle this soon. 👍
Sure thing: https://github.com/pytest-dev/unittest2pytest/pull/24
When running the following to convert asserts:
I consistently get the following output with the below test:
Notice the variable
pattern
which isn't defined anywhere. This is with unittest2pytest==0.3Also, it would be nicer if it didn't use
re.search
and just use the match kwarg to raises. e.g.