aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorMatías Lang <yo@matiaslang.me>2019-01-13 23:55:27 -0300
committerMatías Lang <yo@matiaslang.me>2019-01-13 23:55:27 -0300
commite6da62a50adef20dfd05d89d9571dcaf433f94a3 (patch)
treee82ead634d698c8170bc4c78c85035b8708ff9a8 /test
parent674f92a7c164c538047c970fc42194211856276a (diff)
parent82bc8c7ca2b946e7f022b92ab16ced2924feb284 (diff)
downloadmitmproxy-e6da62a50adef20dfd05d89d9571dcaf433f94a3.tar.gz
mitmproxy-e6da62a50adef20dfd05d89d9571dcaf433f94a3.tar.bz2
mitmproxy-e6da62a50adef20dfd05d89d9571dcaf433f94a3.zip
Merge branch 'master' of https://github.com/mitmproxy/mitmproxy
Diffstat (limited to 'test')
-rw-r--r--test/bench/benchmark.py3
-rw-r--r--test/mitmproxy/addons/test_session.py3
-rw-r--r--test/mitmproxy/coretypes/test_basethread.py2
-rw-r--r--test/mitmproxy/net/http/test_cookies.py4
-rw-r--r--test/mitmproxy/net/test_tcp.py2
5 files changed, 8 insertions, 6 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'
diff --git a/test/mitmproxy/coretypes/test_basethread.py b/test/mitmproxy/coretypes/test_basethread.py
index 4a383fea..6b0ae154 100644
--- a/test/mitmproxy/coretypes/test_basethread.py
+++ b/test/mitmproxy/coretypes/test_basethread.py
@@ -4,4 +4,4 @@ from mitmproxy.coretypes import basethread
def test_basethread():
t = basethread.BaseThread('foobar')
- assert re.match('foobar - age: \d+s', t._threadinfo())
+ assert re.match(r'foobar - age: \d+s', t._threadinfo())
diff --git a/test/mitmproxy/net/http/test_cookies.py b/test/mitmproxy/net/http/test_cookies.py
index 74233cca..06cfe1d3 100644
--- a/test/mitmproxy/net/http/test_cookies.py
+++ b/test/mitmproxy/net/http/test_cookies.py
@@ -27,7 +27,7 @@ cookie_pairs = [
[["one", "uno"], ["two", "due"]]
],
[
- 'one="uno"; two="\due"',
+ 'one="uno"; two="\\due"',
[["one", "uno"], ["two", "due"]]
],
[
@@ -70,7 +70,7 @@ def test_read_key():
def test_read_quoted_string():
tokens = [
[('"foo" x', 0), ("foo", 5)],
- [('"f\oo" x', 0), ("foo", 6)],
+ [('"f\\oo" x', 0), ("foo", 6)],
[(r'"f\\o" x', 0), (r"f\o", 6)],
[(r'"f\\" x', 0), (r"f" + '\\', 5)],
[('"fo\\\"" x', 0), ("fo\"", 6)],
diff --git a/test/mitmproxy/net/test_tcp.py b/test/mitmproxy/net/test_tcp.py
index b6bb7cc1..22a306dc 100644
--- a/test/mitmproxy/net/test_tcp.py
+++ b/test/mitmproxy/net/test_tcp.py
@@ -102,7 +102,7 @@ class TestServerBind(tservers.ServerTestBase):
# We may get an ipv4-mapped ipv6 address here, e.g. ::ffff:127.0.0.1.
# Those still appear as "127.0.0.1" in the table, so we need to strip the prefix.
peername = self.connection.getpeername()
- address = re.sub("^::ffff:(?=\d+.\d+.\d+.\d+$)", "", peername[0])
+ address = re.sub(r"^::ffff:(?=\d+.\d+.\d+.\d+$)", "", peername[0])
port = peername[1]
self.wfile.write(str((address, port)).encode())