MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / check_file

Function check_file

tensorflow/tools/test/check_futures_test.py:57–85  ·  view source on GitHub ↗
(path, old_division)

Source from the content-addressed store, hash-verified

55
56
57def check_file(path, old_division):
58 futures = set()
59 count = 0
60 for line in open(path, encoding='utf-8') if six.PY3 else open(path):
61 count += 1
62 m = FUTURES_PATTERN.match(line)
63 if not m:
64 m = FUTURES_PATTERN_3.match(line)
65 if m:
66 futures.add(m.group(1))
67 else:
68 m = FUTURES_PATTERN_2.match(line)
69 if m:
70 for entry in m.groups():
71 futures.add(entry)
72 if not count:
73 return # Skip empty files
74 if old_division:
75 # This file checks correct behavior without importing division
76 # from __future__, so make sure it's doing that.
77 expected = set(['absolute_import', 'print_function'])
78 if futures != expected:
79 raise AssertionError(('Incorrect futures for old_division file:\n'
80 ' expected = %s\n got = %s') %
81 (' '.join(expected), ' '.join(futures)))
82 else:
83 missing = REQUIRED_FUTURES - futures
84 if missing:
85 raise AssertionError('Missing futures: %s' % ' '.join(missing))
86
87
88def main():

Callers 1

mainFunction · 0.85

Calls 4

matchMethod · 0.45
addMethod · 0.45
groupMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected