| 1 |
"""Helper Methods for testing.""" |
| 2 |
|
| 3 |
from contextlib import contextmanager |
| 4 |
|
| 5 |
|
| 6 |
def eq_(one, other): |
| 7 |
assert one == other, f"{one} != {other}" |
| 8 |
|
| 9 |
|
| 10 |
# hack own assert_raises, because py26 has a different implementation |
| 11 |
@contextmanager |
| 12 |
def assert_raises(exccls, msg): |
| 13 |
"""Check exception of class `exccls` to be raised with message `msg`.""" |
| 14 |
try: |
| 15 |
yield |
| 16 |
raise AssertionError(f"{exccls!r} not raised") |
| 17 |
except Exception as exc: |
| 18 |
assert isinstance(exc, exccls), f"{exc!r} is not a {exccls!r}" |
| 19 |
eq_(str(exc), msg) |