diff --git a/tests/test_error_stuff.py b/tests/test_error_stuff.py
index 8da132409dff26875a39fda343fa1663d3dac33e..7dd6d087e71a65c7da02ccddf3745aea487a2a81 100644
--- a/tests/test_error_stuff.py
+++ b/tests/test_error_stuff.py
@@ -353,14 +353,14 @@ def test_URI_too_long():
     uri_long = 819
     header_long = 815
 
-    with pytest.raises(db.TransactionError) as err:
+    with pytest.raises(db.TransactionError) as excinfo:
         db.execute_query("0123456789" * short)
-    assert "Parsing" in err.msg
+    assert "Parsing" in excinfo.value.msg
 
-    with pytest.raises(db.HTTPURITooLongError) as err:
+    with pytest.raises(db.HTTPURITooLongError) as excinfo:
         db.execute_query("0123456789" * uri_long)
-    assert "414" in err.msg
+    assert "414" in excinfo.value.msg
 
-    with pytest.raises(db.HTTPURITooLongError) as err:
+    with pytest.raises(db.HTTPURITooLongError) as excinfo:
         db.execute_query("0123456789" * header_long)
-    assert "431" in err.msg
+    assert "431" in excinfo.value.msg