Skip to content

Commit 1448034

Browse files
committed
Add deps tests.
1 parent bccefd4 commit 1448034

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

tests/test_deps.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import sys
2+
from types import ModuleType
3+
from unittest import mock
4+
5+
import pytest
6+
7+
from fsutil.deps import require_requests
8+
9+
10+
def test_require_requests_installed():
11+
with mock.patch.dict(sys.modules, {"requests": mock.Mock(spec=ModuleType)}):
12+
requests_module = require_requests()
13+
assert isinstance(requests_module, ModuleType)
14+
15+
16+
def test_require_requests_not_installed():
17+
with mock.patch.dict(sys.modules, {"requests": None}):
18+
with pytest.raises(
19+
ModuleNotFoundError, match="'requests' module is not installed"
20+
):
21+
require_requests()
22+
23+
24+
if __name__ == "__main__":
25+
pytest.main()

0 commit comments

Comments
 (0)