aboutsummaryrefslogtreecommitdiffstats
path: root/test/test_odict.py
diff options
context:
space:
mode:
authorMaximilian Hils <git@maximilianhils.com>2015-04-17 16:29:25 +0200
committerMaximilian Hils <git@maximilianhils.com>2015-04-17 16:29:25 +0200
commit08ba987a84a66d1f8f6464f2800b49cdd461dd72 (patch)
tree091b9832ae6dd629f73f008c9060551795d1c439 /test/test_odict.py
parent0c2ad1edb1af013576f4ac31e05b308ffb440116 (diff)
parent7defb5be862a4251da9d7c530593f7e9be3e739e (diff)
downloadmitmproxy-08ba987a84a66d1f8f6464f2800b49cdd461dd72.tar.gz
mitmproxy-08ba987a84a66d1f8f6464f2800b49cdd461dd72.tar.bz2
mitmproxy-08ba987a84a66d1f8f6464f2800b49cdd461dd72.zip
Merge branch 'master' of github.com:mitmproxy/netlib
Diffstat (limited to 'test/test_odict.py')
-rw-r--r--test/test_odict.py30
1 files changed, 28 insertions, 2 deletions
diff --git a/test/test_odict.py b/test/test_odict.py
index d90bc6e5..c01c4dbe 100644
--- a/test/test_odict.py
+++ b/test/test_odict.py
@@ -6,6 +6,11 @@ class TestODict:
def setUp(self):
self.od = odict.ODict()
+ def test_repr(self):
+ h = odict.ODict()
+ h["one"] = ["two"]
+ assert repr(h)
+
def test_str_err(self):
h = odict.ODict()
tutils.raises(ValueError, h.__setitem__, "key", "foo")
@@ -20,7 +25,7 @@ class TestODict:
"two: tre\r\n",
"\r\n"
]
- out = repr(self.od)
+ out = self.od.format()
for i in expected:
assert out.find(i) >= 0
@@ -39,7 +44,7 @@ class TestODict:
self.od["one"] = ["uno"]
expected1 = "one: uno\r\n"
expected2 = "\r\n"
- out = repr(self.od)
+ out = self.od.format()
assert out.find(expected1) >= 0
assert out.find(expected2) >= 0
@@ -109,6 +114,12 @@ class TestODict:
assert self.od.get_first("one") == "two"
assert self.od.get_first("two") == None
+ def test_extend(self):
+ a = odict.ODict([["a", "b"], ["c", "d"]])
+ b = odict.ODict([["a", "b"], ["e", "f"]])
+ a.extend(b)
+ assert len(a) == 4
+ assert a["a"] == ["b", "b"]
class TestODictCaseless:
def setUp(self):
@@ -145,3 +156,18 @@ class TestODictCaseless:
self.od.add("bar", 2)
assert len(self.od.keys()) == 2
+ def test_add_order(self):
+ od = odict.ODict(
+ [
+ ["one", "uno"],
+ ["two", "due"],
+ ["three", "tre"],
+ ]
+ )
+ od["two"] = ["foo", "bar"]
+ assert od.lst == [
+ ["one", "uno"],
+ ["two", "foo"],
+ ["three", "tre"],
+ ["two", "bar"],
+ ]