From c36bc9b072e3d2b9d37093f27e378d8b2bc13332 Mon Sep 17 00:00:00 2001 From: Lukas Geiger Date: Fri, 10 Jul 2020 12:08:34 +0200 Subject: [PATCH] Fix FileIO test for Python < 3.6 --- tensorflow/python/lib/io/file_io_test.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tensorflow/python/lib/io/file_io_test.py b/tensorflow/python/lib/io/file_io_test.py index ad99d9daf25..6339ed85abe 100644 --- a/tensorflow/python/lib/io/file_io_test.py +++ b/tensorflow/python/lib/io/file_io_test.py @@ -20,7 +20,6 @@ from __future__ import division from __future__ import print_function import os.path -import pathlib from absl.testing import parameterized import numpy as np @@ -31,9 +30,18 @@ from tensorflow.python.platform import gfile from tensorflow.python.platform import test +class PathLike(object): + """Backport of pathlib.Path for Python < 3.6""" + def __init__(self, name): + self.name = name + + def __fspath__(self): + return self.name + + run_all_path_types = parameterized.named_parameters( ("str", os.path.join), - ("pathlib", lambda *paths: pathlib.Path(os.path.join(*paths)))) + ("pathlike", lambda *paths: PathLike(os.path.join(*paths)))) class FileIoTest(test.TestCase, parameterized.TestCase):