html_url,issue_url,id,node_id,user,created_at,updated_at,author_association,body,reactions,performed_via_github_app,issue
https://github.com/pydata/xarray/pull/6251#issuecomment-1033105848,https://api.github.com/repos/pydata/xarray/issues/6251,1033105848,IC_kwDOAMm_X849k_G4,14808389,2022-02-08T22:02:29Z,2022-02-08T22:02:29Z,MEMBER,"what do you think about adding `no_warnings()` and `suppress_warnings()` to `xarray.tests.__init__`? For those `pytest` [recommends](https://docs.pytest.org/en/7.0.x/how-to/capture-warnings.html#additional-use-cases-of-warnings-in-tests)
```python
# no_warnings
with warnings.catch_warnings():
warnings.simplefilter(""error"")
...
# or, without the stacktrace
with warnings.catch_warnings(record=True) as record:
...
assert len(record) == 0
# or, with `pytest.warns()`
with pytest.warns() as record:
...
assert len(record) == 0
# suppress
with warnings.catch_warnings():
warnings.simplefilter(""ignore"")
...
```
but those can easily get a name and be a bit easier to read. E.g. for the version of `no_warnings()` used in this PR:
```python
@contextmanager
def no_warnings():
with warnings.catch_warnings(record=True) as record:
yield
assert len(record) == 0
```","{""total_count"": 0, ""+1"": 0, ""-1"": 0, ""laugh"": 0, ""hooray"": 0, ""confused"": 0, ""heart"": 0, ""rocket"": 0, ""eyes"": 0}",,1126086052