-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e7ec83e
commit e298edf
Showing
5 changed files
with
168 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
from unittest.mock import patch | ||
|
||
from redcat.utils import get_available_devices | ||
|
||
########################################### | ||
# Tests for get_available_devices # | ||
########################################### | ||
|
||
|
||
@patch("torch.cuda.is_available", lambda *args, **kwargs: False) | ||
def test_get_available_devices_cpu() -> None: | ||
assert get_available_devices() == ("cpu",) | ||
|
||
|
||
@patch("torch.cuda.is_available", lambda *args, **kwargs: True) | ||
@patch("torch.cuda.device_count", lambda *args, **kwargs: 1) | ||
def test_get_available_devices_cpu_and_gpu() -> None: | ||
assert get_available_devices() == ("cpu", "cuda:0") |