Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(test): use match kwarg to check warning messages
Use `pytest.warns` `match` to assert that a warning with the correct message was emitted, instead of obtaining a list of warnings emitted matching a type and asserting on that. This should result in better DX since warnings which match the type but not the message are unaffected by the context manager, and bubble up to pytest instead of causing a (relatively opaque) test failure. The change has the downside of no longer being able to assert that the warning is only emitted once. This is because in Python 3.6 and 3.7, warnings that are normally ignored but raised during a `warns` context manager block still end up in the record, despite being ignored for the purposes of checking whether or not the context manager's assertion succeeded or not. Thus, suppressed warnings will still fail our test if we assert on the length of the record, even though they are otherwise completely ignored (only on these Python versions). This is probably a pytest bug, however I have not yet had the time to see if it is reported or writing up a report.
- Loading branch information