mirror of
https://github.com/curl/curl.git
synced 2026-08-24 21:43:32 +03:00
pytest: close file handles after use, and two minor tidy-ups
Also: - drop two unreachable return statements. - test_17_ssl_use: avoid implicit string concatenations in lists. Reported by GitHub CodeQL Closes #21916
This commit is contained in:
parent
2dfd265d66
commit
8145476d5d
15 changed files with 149 additions and 84 deletions
|
|
@ -104,8 +104,9 @@ class LocalClient:
|
|||
log.warning(f'Timeout after {self._timeout}s: {args}')
|
||||
exitcode = -1
|
||||
exception = 'TimeoutExpired'
|
||||
coutput = open(self._stdoutfile).readlines()
|
||||
cerrput = open(self._stderrfile).readlines()
|
||||
with open(self._stdoutfile) as fout, open(self._stderrfile) as ferr:
|
||||
coutput = fout.readlines()
|
||||
cerrput = ferr.readlines()
|
||||
return ExecResult(args=myargs, exit_code=exitcode, exception=exception,
|
||||
stdout=coutput, stderr=cerrput,
|
||||
duration=datetime.now() - start)
|
||||
|
|
@ -113,8 +114,10 @@ class LocalClient:
|
|||
def dump_logs(self):
|
||||
lines = []
|
||||
lines.append('>>--stdout ----------------------------------------------\n')
|
||||
lines.extend(open(self._stdoutfile).readlines())
|
||||
with open(self._stdoutfile) as cstdout:
|
||||
lines.extend(cstdout.readlines())
|
||||
lines.append('>>--stderr ----------------------------------------------\n')
|
||||
lines.extend(open(self._stderrfile).readlines())
|
||||
with open(self._stderrfile) as cstderr:
|
||||
lines.extend(cstderr.readlines())
|
||||
lines.append('<<-------------------------------------------------------\n')
|
||||
return ''.join(lines)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue