Skip to content

Commit

Permalink
Updates for new pytest release
Browse files Browse the repository at this point in the history
str() for ExceptionInfo changed its format, so we are now using
the newly-introduced `ExceptionInfo.match(regexp)` method instead.
Depend on pytest>5 but <6 to prevent this kind of surprise in the future.

See also: pytest-dev/pytest#5412
  • Loading branch information
sk1p committed Jul 1, 2019
1 parent 5796b98 commit 2140b9f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion test_requirements.txt
@@ -1,4 +1,4 @@
pytest
pytest>=5,<6
pytest-cov
pytest-asyncio
aiohttp
Expand Down
9 changes: 5 additions & 4 deletions tests/io/test_empad.py
Expand Up @@ -141,19 +141,20 @@ def test_invalid_size():
scan_size=(4, 5),
)
ds = ds.initialize()
with pytest.raises(DataSetException) as e:
with pytest.raises(DataSetException) as einfo:
ds.check_valid()
assert "invalid filesize" in str(e)

assert einfo.match("invalid filesize")


def test_nonexistent():
ds = EMPADDataSet(
path="/does/not/exist.raw",
scan_size=(4, 4),
)
with pytest.raises(DataSetException) as e:
with pytest.raises(DataSetException) as einfo:
ds = ds.initialize()
assert "No such file or directory" in str(e)
assert einfo.match("No such file or directory")


def test_detect_fail():
Expand Down
6 changes: 3 additions & 3 deletions tests/test_analysis_base.py
Expand Up @@ -14,10 +14,10 @@ def test_result_set():

results = AnalysisResultSet([result])

with pytest.raises(AttributeError) as e:
with pytest.raises(AttributeError) as einfo:
results.foo
assert "not found" in str(e)
assert "have: test" in str(e)
assert einfo.match("not found")
assert einfo.match("have: test")

assert results.test == result
assert len(results) == 1
Expand Down

0 comments on commit 2140b9f

Please sign in to comment.