Fix indeterminacy in sticky cookie tests

How has this not bitten us before?
This commit is contained in:
Aldo Cortesi 2016-07-14 12:59:00 +12:00
parent cf3b3d206a
commit 703c05066e

View File

@ -64,8 +64,11 @@ class TestStickyCookie(mastertest.MasterTest):
self._response(s, m, sc, c, "www.google.com") self._response(s, m, sc, c, "www.google.com")
assert sc.jar.keys() assert sc.jar.keys()
self._response(s, m, sc, "SSID=mooo", "www.google.com") sc.jar.clear()
assert sc.jar.keys()[0] == ('www.google.com', 80, '/') self._response(
s, m, sc, "SSID=mooo", "www.google.com"
)
assert list(sc.jar.keys())[0] == ('www.google.com', 80, '/')
def test_response_multiple(self): def test_response_multiple(self):
s, m, sc = self.mk() s, m, sc = self.mk()
@ -76,7 +79,7 @@ class TestStickyCookie(mastertest.MasterTest):
f = self._response(s, m, sc, c1, "www.google.com") f = self._response(s, m, sc, c1, "www.google.com")
f.response.headers["Set-Cookie"] = c2 f.response.headers["Set-Cookie"] = c2
self.invoke(m, "response", f) self.invoke(m, "response", f)
googlekey = sc.jar.keys()[0] googlekey = list(sc.jar.keys())[0]
assert len(sc.jar[googlekey].keys()) == 2 assert len(sc.jar[googlekey].keys()) == 2
def test_response_weird(self): def test_response_weird(self):
@ -93,7 +96,7 @@ class TestStickyCookie(mastertest.MasterTest):
for c in cs: for c in cs:
f.response.headers["Set-Cookie"] = c f.response.headers["Set-Cookie"] = c
self.invoke(m, "response", f) self.invoke(m, "response", f)
googlekey = sc.jar.keys()[0] googlekey = list(sc.jar.keys())[0]
assert len(sc.jar[googlekey].keys()) == len(cs) assert len(sc.jar[googlekey].keys()) == len(cs)
def test_response_overwrite(self): def test_response_overwrite(self):
@ -105,9 +108,9 @@ class TestStickyCookie(mastertest.MasterTest):
f = self._response(s, m, sc, c1, "www.google.com") f = self._response(s, m, sc, c1, "www.google.com")
f.response.headers["Set-Cookie"] = c2 f.response.headers["Set-Cookie"] = c2
self.invoke(m, "response", f) self.invoke(m, "response", f)
googlekey = sc.jar.keys()[0] googlekey = list(sc.jar.keys())[0]
assert len(sc.jar[googlekey].keys()) == 1 assert len(sc.jar[googlekey].keys()) == 1
assert sc.jar[googlekey]["somecookie"].items()[0][1] == "newvalue" assert list(sc.jar[googlekey]["somecookie"].items())[0][1] == "newvalue"
def test_request(self): def test_request(self):
s, m, sc = self.mk() s, m, sc = self.mk()