4 ms·
If you liked the nice simple assert, you can get an imitation in Python tests using py.test: http://pytest.org/latest/assert.html http://pytest.org/latest/asser
by Erwin 13y ago
If you liked the nice simple assert, you can get an imitation in Python tests using py.test: http://pytest.org/latest/assert.html http://pytest.org/latest/assert.html
Source code:
def test_function():
assert f() == 4
Output:
def test_function():
> assert f() == 4
E assert 3 == 4
E + where 3 = f()
Here's how it works: http://pytest.org/latest/assert.html#assert-details http://pytest.org/latest/assert.html#assert-details -- when importing the test module, all simple asserts are rewritten (which has some limitations if side effects are involved).
No more verbose self.assertTheItemIsInThisList(item, list) at least.
- subleq 13y agoThe problems with side effects have been fixed for a while: http://pybites.blogspot.com/2011/07/behind-scenes-of-pytests-new-assertion.html http://pybites.blogspot.com/2011/07/behind-scenes-of-pytests...