1diff --git a/jenkinsapi_tests/unittests/test_build.py b/jenkinsapi_tests/unittests/test_build.py
2index 2e2c2f4..9de816a 100644
3--- a/jenkinsapi_tests/unittests/test_build.py
4+++ b/jenkinsapi_tests/unittests/test_build.py
5@@ -3,6 +3,7 @@ import pytest
6 import pytz
7 from . import configs
8 import datetime
9+import warnings
10 from jenkinsapi.build import Build
11 from jenkinsapi.job import Job
12
13@@ -252,7 +253,7 @@ def test_build_env_vars_wo_injected_env_vars_plugin(monkeypatch, build):
14 monkeypatch.setattr(Build, "get_data", fake_get_data)
15
16 with pytest.raises(requests.HTTPError) as excinfo:
17- with pytest.warns(None) as record:
18+ with warnings.catch_warnings(record=True) as record:
19 build.get_env_vars()
20 assert "404" == str(excinfo.value)
21 assert len(record) == 1
22@@ -269,7 +270,7 @@ def test_build_env_vars_other_exception(monkeypatch, build):
23 monkeypatch.setattr(Build, "get_data", fake_get_data)
24
25 with pytest.raises(Exception) as excinfo:
26- with pytest.warns(None) as record:
27+ with warnings.catch_warnings(record=True) as record:
28 build.get_env_vars()
29 assert "" == str(excinfo.value)
30 assert len(record) == 0