Add missing module __spec__ (#13321)

* added missing __spec__ to _LazyModule

* test __spec__ is not None after module import

* changed module_spec arg to be optional in _LazyModule

* fix style issue

* added module spec test to test_file_utils
This commit is contained in:
Laura Hanu
2021-08-30 17:39:05 +01:00
committed by GitHub
parent 4ebe798ff2
commit 35236b870e
3 changed files with 14 additions and 2 deletions

View File

@@ -12,9 +12,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import importlib
import unittest
import requests
import transformers
# Try to import everything from transformers to ensure every object can be loaded.
from transformers import * # noqa F406
@@ -38,6 +40,11 @@ PINNED_SHA256 = "4b243c475af8d0a7754e87d7d096c92e5199ec2fe168a2ee7998e3b8e9bcb1d
# Sha-256 of pytorch_model.bin on the top of `main`, for checking purposes
def test_module_spec():
assert transformers.__spec__ is not None
assert importlib.util.find_spec("transformers") is not None
class GetFromCacheTests(unittest.TestCase):
def test_bogus_url(self):
# This lets us simulate no connection