'file' is a core name which was being overridden. This was not of any
consequence, but the rename leads to the more common pattern:
with open(filename) as f:
---
test/test_cautodoc.py | 6 +++---
test/testenv.py | 8 ++++----
2 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/test/test_cautodoc.py b/test/test_cautodoc.py
index a1aff01..4d7c746 100755
--- a/test/test_cautodoc.py
+++ b/test/test_cautodoc.py
@@ -14,12 +14,12 @@ def _get_output(input_filename, app, status, warning,
**options):
shutil.copyfile(input_filename,
testenv.modify_filename(input_filename, dir=app.srcdir))
- with open(os.path.join(app.srcdir, 'index.rst'), 'w') as file:
+ with open(os.path.join(app.srcdir, 'index.rst'), 'w') as f:
fmt = '.. c:autodoc:: {source}\n'
- file.write(fmt.format(source=os.path.basename(input_filename)))
+ f.write(fmt.format(source=os.path.basename(input_filename)))
for key in [k for k in options.keys() if k in
testenv.directive_options]:
fmt = ' :{key}: {value}\n'
- file.write(fmt.format(key=key, value=options[key]))
+ f.write(fmt.format(key=key, value=options[key]))
app.build()
diff --git a/test/testenv.py b/test/testenv.py
index b6842a8..c86749a 100644
--- a/test/testenv.py
+++ b/test/testenv.py
@@ -37,8 +37,8 @@ def get_testcase_options(testcase):
# options are optional
options = {}
if os.path.isfile(options_filename):
- with open(options_filename, 'r') as file:
- for line in file.readlines():
+ with open(options_filename, 'r') as f:
+ for line in f.readlines():
opt = [x.strip() for x in line.split('=', 1)]
if opt[0] != '':
if len(opt) == 2:
@@ -64,8 +64,8 @@ def modify_filename(filename, **kwargs):
def read_file(filename, **kwargs):
filename = modify_filename(filename, **kwargs)
- with open(filename, 'r') as file:
- expected = file.read()
+ with open(filename, 'r') as f:
+ expected = f.read()
return expected
--
2.21.0