aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/bench/benchmark.py3
-rw-r--r--test/mitmproxy/addons/test_session.py3
2 files changed, 4 insertions, 2 deletions
diff --git a/test/bench/benchmark.py b/test/bench/benchmark.py
index 84ec6005..076ad6c9 100644
--- a/test/bench/benchmark.py
+++ b/test/bench/benchmark.py
@@ -31,7 +31,8 @@ class Benchmark:
stdout=asyncio.subprocess.PIPE
)
stdout, _ = await traf.communicate()
- open(ctx.options.benchmark_save_path + ".bench", mode="wb").write(stdout)
+ with open(ctx.options.benchmark_save_path + ".bench", mode="wb") as f:
+ f.write(stdout)
ctx.log.error("Proxy saw %s requests, %s responses" % (self.reqs, self.resps))
ctx.log.error(stdout.decode("ascii"))
backend.kill()
diff --git a/test/mitmproxy/addons/test_session.py b/test/mitmproxy/addons/test_session.py
index 20feb69d..97351426 100644
--- a/test/mitmproxy/addons/test_session.py
+++ b/test/mitmproxy/addons/test_session.py
@@ -68,7 +68,8 @@ class TestSession:
os.remove(path)
con = sqlite3.connect(path)
script_path = pkg_data.path("io/sql/session_create.sql")
- qry = open(script_path, 'r').read()
+ with open(script_path) as f:
+ qry = f.read()
with con:
con.executescript(qry)
blob = b'blob_of_data'