Skip to content

Commit cd65de2

Browse files
Merge pull request #15 from mimi1vx/patch-1
Use pytest.raises as context manager
2 parents e409195 + 3490251 commit cd65de2

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

test_apipkg.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -320,8 +320,10 @@ def test_error_loading_one_element(monkeypatch, tmpdir):
320320
import errorloading1
321321
assert isinstance(errorloading1, apipkg.ApiModule)
322322
assert errorloading1.y == 0
323-
pytest.raises(ImportError, 'errorloading1.x')
324-
pytest.raises(ImportError, 'errorloading1.x')
323+
with pytest.raises(ImportError):
324+
errorloading1.x
325+
with pytest.raises(ImportError):
326+
errorloading1.x
325327

326328

327329
def test_onfirstaccess(tmpdir, monkeypatch):
@@ -493,7 +495,9 @@ def doit():
493495
assert doit is orig.doit
494496

495497
del proxy.doit
496-
pytest.raises(AttributeError, "orig.doit")
498+
499+
with pytest.raises(AttributeError):
500+
orig.doit
497501

498502
proxy.doit = doit
499503
assert orig.doit is doit

0 commit comments

Comments
 (0)