Skip to content

Commit

Permalink
fix(test): check warning type in tests
Browse files Browse the repository at this point in the history
The message returned by `pytest.warns` can now be `str`, so make sure
that it is in fact `Warning`. This fixes a mypy error.
  • Loading branch information
ethanwu10 committed Nov 11, 2020
1 parent 66cb3fd commit 5217562
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions tests/challenge/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ def test_warn_multiline_flag(configloader, test_datadir) -> None:
cfg, errors = configloader.check_config(test_datadir / "challenge.yml")
assert errors is None
assert len(record) == 1
assert isinstance(record[0].message, Warning)
assert (
str(record[0].message.args[0])
== "Flag contains multiple lines; is this intended?"
Expand Down
2 changes: 2 additions & 0 deletions tests/project/test_assets.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,7 @@ def test_extra_file(self, datadir: Path, am_fn: assets.AssetManager) -> None:
with pytest.warns(RuntimeWarning) as record:
ctx.sync(check=True)
assert len(record) == 1
assert isinstance(record[0].message, Warning)
assert "Unexpected item found in cache: " in str(record[0].message.args[0])
assert not file1.exists()

Expand All @@ -317,6 +318,7 @@ def test_extra_dir(self, datadir: Path, am_fn: assets.AssetManager) -> None:
with pytest.warns(RuntimeWarning) as record:
ctx.sync(check=True)
assert len(record) == 1
assert isinstance(record[0].message, Warning)
assert "Unexpected item found in cache: " in str(record[0].message.args[0])
assert not dir1.exists()

Expand Down

0 comments on commit 5217562

Please sign in to comment.