-
Notifications
You must be signed in to change notification settings - Fork 139
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
Showing
5 changed files
with
107 additions
and
20 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
54 changes: 54 additions & 0 deletions
54
tensorflow_recommenders_addons/utils/tests/test_resource_loader.py
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,54 @@ | ||
import unittest | ||
from unittest.mock import patch, Mock | ||
|
||
import pkg_resources | ||
import tensorflow as tf | ||
|
||
from tensorflow_recommenders_addons.utils.resource_loader import abi_is_compatible | ||
|
||
|
||
class TestTensorFlowCompatibility(unittest.TestCase): | ||
|
||
@patch('pkg_resources.get_distribution') | ||
@patch('tensorflow.__version__', '2.12.0') | ||
def test_compatible_version(self, mock_get_distribution): | ||
mock_pkg = Mock() | ||
mock_requirement = Mock() | ||
mock_requirement.name = 'tensorflow' | ||
mock_requirement.specs = [('>=', '2.11.0'), ('<=', '2.15.1')] | ||
mock_pkg.requires.return_value = [mock_requirement] | ||
mock_get_distribution.return_value = mock_pkg | ||
self.assertTrue(abi_is_compatible()) | ||
|
||
@patch('pkg_resources.get_distribution') | ||
@patch('tensorflow.__version__', '2.10.0') | ||
def test_incompatible_version_below_range(self, mock_get_distribution): | ||
mock_pkg = Mock() | ||
mock_requirement = Mock() | ||
mock_requirement.name = 'tensorflow' | ||
mock_requirement.specs = [('>=', '2.11.0'), ('<=', '2.15.1')] | ||
mock_pkg.requires.return_value = [mock_requirement] | ||
mock_get_distribution.return_value = mock_pkg | ||
self.assertFalse(abi_is_compatible()) | ||
|
||
@patch('pkg_resources.get_distribution') | ||
@patch('tensorflow.__version__', '2.16.0') | ||
def test_incompatible_version_above_range(self, mock_get_distribution): | ||
mock_pkg = Mock() | ||
mock_requirement = Mock() | ||
mock_requirement.name = 'tensorflow' | ||
mock_requirement.specs = [('>=', '2.11.0'), ('<=', '2.15.1')] | ||
mock_pkg.requires.return_value = [mock_requirement] | ||
mock_get_distribution.return_value = mock_pkg | ||
self.assertFalse(abi_is_compatible()) | ||
|
||
@patch('pkg_resources.get_distribution') | ||
@patch('tensorflow.__version__', '2.13.0-dev20240528') | ||
def test_dev_version(self, mock_get_distribution): | ||
mock_pkg = Mock() | ||
mock_requirement = Mock() | ||
mock_requirement.name = 'tensorflow' | ||
mock_requirement.specs = [('>=', '2.11.0'), ('<=', '2.15.1')] | ||
mock_pkg.requires.return_value = [mock_requirement] | ||
mock_get_distribution.return_value = mock_pkg | ||
self.assertFalse(abi_is_compatible()) |
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 |
---|---|---|
@@ -1 +1 @@ | ||
yapf == 0.30.0 | ||
yapf == 0.40.2 |