bioforensics / MicroHapulator

Tools for empirical microhaplotype calling, forensic interpretation, and simulation.
https://microhapulator.readthedocs.io/
Other
6 stars 1 forks source link

Error strings accessed differently in pytest 5.x #52

Closed standage closed 5 years ago

standage commented 5 years ago

Until now, I've been using this approach to check error strings in the test suite.

with pytest.raises(ValueError) as ve:
    microhapulator.some.operation(baddata)
assert 'expected error message' in str(ve)

The str(ve) approach no longer works with pytest 5.x. The pytest version has been pinned temporarily in the CI configuration, but this should be addressed soon.

standage commented 5 years ago

The new syntax:

with pytest.raises(ValueError, match=r'expected error message') as ve:
    microhapulator.some.operation(baddata)

Relevant documentation: http://doc.pytest.org/en/latest/assert.html#assertions-about-expected-exceptions