Write an actual test for resource_loader_test

Exercise the code paths it triggers.

Disable it on windows and pip packages for now.

PiperOrigin-RevId: 293910406
Change-Id: Ie84a3a85ff1f471e3d7ed4b192701667481e8324
This commit is contained in:
Gunhan Gulsoy 2020-02-07 15:40:49 -08:00 committed by TensorFlower Gardener
parent 03a653e4d7
commit 52a820c507
2 changed files with 14 additions and 1 deletions

View File

@ -285,7 +285,14 @@ tf_py_test(
name = "resource_loader_test", name = "resource_loader_test",
size = "small", size = "small",
srcs = ["platform/resource_loader_test.py"], srcs = ["platform/resource_loader_test.py"],
data = [
"platform/resource_loader.py",
],
python_version = "PY3", python_version = "PY3",
tags = [
"no_pip",
"no_windows",
],
deps = [ deps = [
":platform", ":platform",
":platform_test", ":platform_test",

View File

@ -21,11 +21,17 @@ from tensorflow.python.platform import googletest
from tensorflow.python.platform import resource_loader from tensorflow.python.platform import resource_loader
class DefaultResourceLoaderTest(googletest.TestCase): class ResourceLoaderTest(googletest.TestCase):
def test_exception(self): def test_exception(self):
with self.assertRaises(IOError): with self.assertRaises(IOError):
resource_loader.load_resource("/fake/file/path/dne") resource_loader.load_resource("/fake/file/path/dne")
def test_exists(self):
contents = resource_loader.load_resource(
"python/platform/resource_loader.py")
self.assertIn(b"tensorflow", contents)
if __name__ == "__main__": if __name__ == "__main__":
googletest.main() googletest.main()