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:
Viktor Szakats 2026-06-08 23:27:32 +02:00
parent 2dfd265d66
commit 8145476d5d
No known key found for this signature in database
15 changed files with 149 additions and 84 deletions

View file

@ -57,7 +57,6 @@ class TestProxy:
if m:
return m.group(1)
assert False, f'tunnel protocol not found in:\n{"".join(r.trace_lines)}'
return None
# download via http: proxy (no tunnel)
def test_10_01_proxy_http(self, env: Env, httpd):
@ -105,9 +104,11 @@ class TestProxy:
extra_args=xargs)
r.check_response(count=count, http_status=200,
protocol='HTTP/2' if proto == 'h2' else 'HTTP/1.1')
indata = open(srcfile).readlines()
with open(srcfile) as fi:
indata = fi.readlines()
for i in range(count):
respdata = open(curl.response_file(i)).readlines()
with open(curl.response_file(i)) as fr:
respdata = fr.readlines()
assert respdata == indata
# download http: via http: proxytunnel
@ -229,9 +230,11 @@ class TestProxy:
assert self.get_tunnel_proto_used(r) == tunnel
r.check_response(count=count, http_status=200)
assert r.total_connects == 1, r.dump_logs()
indata = open(srcfile).readlines()
with open(srcfile) as fi:
indata = fi.readlines()
for i in range(count):
respdata = open(curl.response_file(i)).readlines()
with open(curl.response_file(i)) as fr:
respdata = fr.readlines()
assert respdata == indata, f'response {i} differs'
@pytest.mark.skipif(condition=not Env.have_ssl_curl(), reason="curl without SSL")