Commit 9cac7637 authored by cclauss's avatar cclauss
Browse files

file() was removed in Python 3 (en masse)

parent c24e1f41
...@@ -45,7 +45,7 @@ class DragnnModelSaverLibTest(test_util.TensorFlowTestCase): ...@@ -45,7 +45,7 @@ class DragnnModelSaverLibTest(test_util.TensorFlowTestCase):
master_spec = spec_pb2.MasterSpec() master_spec = spec_pb2.MasterSpec()
root_dir = os.path.join(FLAGS.test_srcdir, root_dir = os.path.join(FLAGS.test_srcdir,
'dragnn/python') 'dragnn/python')
with file(os.path.join(root_dir, 'testdata', spec_path), 'r') as fin: with open(os.path.join(root_dir, 'testdata', spec_path), 'r') as fin:
text_format.Parse(fin.read().replace('TOPDIR', root_dir), master_spec) text_format.Parse(fin.read().replace('TOPDIR', root_dir), master_spec)
return master_spec return master_spec
......
...@@ -246,7 +246,7 @@ class GraphBuilderTest(test_util.TensorFlowTestCase): ...@@ -246,7 +246,7 @@ class GraphBuilderTest(test_util.TensorFlowTestCase):
master_spec = spec_pb2.MasterSpec() master_spec = spec_pb2.MasterSpec()
testdata = os.path.join(FLAGS.test_srcdir, testdata = os.path.join(FLAGS.test_srcdir,
'dragnn/core/testdata') 'dragnn/core/testdata')
with file(os.path.join(testdata, spec_path), 'r') as fin: with open(os.path.join(testdata, spec_path), 'r') as fin:
text_format.Parse(fin.read().replace('TESTDATA', testdata), master_spec) text_format.Parse(fin.read().replace('TESTDATA', testdata), master_spec)
return master_spec return master_spec
......
...@@ -140,7 +140,7 @@ class LexiconBuilderTest(test_util.TensorFlowTestCase): ...@@ -140,7 +140,7 @@ class LexiconBuilderTest(test_util.TensorFlowTestCase):
self.assertTrue(last) self.assertTrue(last)
def ValidateTagToCategoryMap(self): def ValidateTagToCategoryMap(self):
with file(os.path.join(FLAGS.test_tmpdir, 'tag-to-category'), 'r') as f: with open(os.path.join(FLAGS.test_tmpdir, 'tag-to-category'), 'r') as f:
entries = [line.strip().split('\t') for line in f.readlines()] entries = [line.strip().split('\t') for line in f.readlines()]
for tag, category in entries: for tag, category in entries:
self.assertIn(tag, TAGS) self.assertIn(tag, TAGS)
...@@ -148,7 +148,7 @@ class LexiconBuilderTest(test_util.TensorFlowTestCase): ...@@ -148,7 +148,7 @@ class LexiconBuilderTest(test_util.TensorFlowTestCase):
def LoadMap(self, map_name): def LoadMap(self, map_name):
loaded_map = {} loaded_map = {}
with file(os.path.join(FLAGS.test_tmpdir, map_name), 'r') as f: with open(os.path.join(FLAGS.test_tmpdir, map_name), 'r') as f:
for line in f: for line in f:
entries = line.strip().split(' ') entries = line.strip().split(' ')
if len(entries) >= 2: if len(entries) >= 2:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment