aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMaximilian Hils <git@maximilianhils.com>2013-12-16 04:47:29 +0100
committerMaximilian Hils <git@maximilianhils.com>2013-12-16 04:47:29 +0100
commite0d376381efa3394e23ed60283dc45b7893e8e1e (patch)
treee2b855ac15ed2f2892426e8288bcb5c9dd260cd6
parent34f5f5a5c185517b6ddfdff14a17bc919e296d75 (diff)
downloadmitmproxy-e0d376381efa3394e23ed60283dc45b7893e8e1e.tar.gz
mitmproxy-e0d376381efa3394e23ed60283dc45b7893e8e1e.tar.bz2
mitmproxy-e0d376381efa3394e23ed60283dc45b7893e8e1e.zip
fix windows compatibility
-rw-r--r--README.mkd2
-rw-r--r--libpathod/language.py2
-rw-r--r--test/test_language.py11
3 files changed, 10 insertions, 5 deletions
diff --git a/README.mkd b/README.mkd
index 471ff106..01b92fcf 100644
--- a/README.mkd
+++ b/README.mkd
@@ -1,3 +1,5 @@
+[![Build Status](https://travis-ci.org/mitmproxy/pathod.png)](https://travis-ci.org/mitmproxy/pathod) [![Coverage Status](https://coveralls.io/repos/mitmproxy/pathod/badge.png)](https://coveralls.io/r/mitmproxy/pathod)
+
__pathod__ is a collection of pathological tools for testing and torturing HTTP
clients and servers. The project has three components:
diff --git a/libpathod/language.py b/libpathod/language.py
index 5cce6fde..4c1a4977 100644
--- a/libpathod/language.py
+++ b/libpathod/language.py
@@ -182,7 +182,7 @@ class FileGenerator:
def __init__(self, path):
self.path = path
self.fp = file(path, "rb")
- self.map = mmap.mmap(self.fp.fileno(), 0, prot=mmap.PROT_READ)
+ self.map = mmap.mmap(self.fp.fileno(), 0, access=mmap.ACCESS_READ)
def __len__(self):
return len(self.map)
diff --git a/test/test_language.py b/test/test_language.py
index 18865761..5e9176ab 100644
--- a/test/test_language.py
+++ b/test/test_language.py
@@ -95,9 +95,8 @@ class TestValueFile:
v = language.Value.parseString("<path")[0]
with tutils.tmpdir() as t:
p = os.path.join(t, "path")
- f = open(p, "wb")
- f.write("x"*10000)
- f.close()
+ with open(p, "wb") as f:
+ f.write("x" * 10000)
assert v.get_generator(dict(staticdir=t))
@@ -152,6 +151,7 @@ class TestMisc:
assert g[-1] == "x"
assert g[0:5] == "xxxxx"
assert repr(g)
+ del g # remove all references to FileGenerator instance to close the file handle.
def test_value(self):
assert language.Value.parseString("'val'")[0].val == "val"
@@ -697,7 +697,10 @@ class TestResponse:
assert r.actions[0].spec() == "pr,10"
def test_parse_stress(self):
- r = language.parse_response({}, "400:b@100g")
+ # While larger values are known to work on linux,
+ # len() technically returns an int and a python 2.7 int on windows has 32bit precision.
+ # Therefore, we should keep the body length < 2147483647 bytes in our tests.
+ r = language.parse_response({}, "400:b@1g")
assert r.length({})
def test_spec(self):