home / github / issue_comments

Menu
  • GraphQL API
  • Search all tables

issue_comments: 1033137904

This data as json

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-1033137904 https://api.github.com/repos/pydata/xarray/issues/6251 1033137904 IC_kwDOAMm_X849lG7w 10194086 2022-02-08T22:46:00Z 2022-02-08T22:46:00Z MEMBER

Nice suggestion. How about assert_no_warnings? Not sure if supress_warnings is a bit over the top?

```python from contextlib import contextmanager import warnings

@contextmanager def assert_no_warnings():

with warnings.catch_warnings(record=True) as record:
    yield
    assert len(record) == 0, "got unexpected warning(s)"

@contextmanager def supress_warnings(*messages):

messages = ("",) if not messages else messages
with warnings.catch_warnings():
    for message in messages:
        warnings.filterwarnings("ignore", message)
    yield

```

```python with supress_warnings(): warnings.warn("test")

with supress_warnings("test"): warnings.warn("test")

with supress_warnings("not test", "something else"): warnings.warn("test")

with assert_no_warnings(): pass

with assert_no_warnings(): warnings.warn("test") ```

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
  1126086052
Powered by Datasette · Queries took 0.696ms · About: xarray-datasette