Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bump werkzeug from 2.2.3 to 2.3.7 #1186

Merged
merged 3 commits into from
Aug 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions requirements/test.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Flask==2.2.3
werkzeug==2.2.3
Flask==2.3.2
werkzeug==2.3.7
coverage==7.3.0
argparse
Django>=2.0.6
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def get_version_data() -> dict:
extras_require={
"zope.testbrowser": ["zope.testbrowser>=6.0", "lxml>=4.2.4", "cssselect"],
"django": ["Django>=2.0.6", "lxml>=4.2.4", "cssselect"],
"flask": ["Flask>=2.0.2", "lxml>=4.2.4", "cssselect"],
"flask": ["Flask>=2.3.2", "lxml>=4.2.4", "cssselect"],
"selenium": ["selenium>=4.1.0,<4.5.0"],
},
tests_require=["coverage", "flask"],
Expand Down
23 changes: 12 additions & 11 deletions splinter/driver/flaskclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,41 +16,42 @@
class CookieManager(CookieManagerAPI):
def add(self, cookie, **kwargs):
for key, value in cookie.items():
kwargs["server_name"] = "localhost"
kwargs["key"] = key
kwargs["value"] = value
self.driver.set_cookie(**kwargs)
self.driver.set_cookie(
key=key,
value=value,
domain="localhost",
**kwargs,
)

def delete(self, *cookies):
if cookies:
for cookie in cookies:
try:
self.driver.delete_cookie("localhost", cookie)
self.driver.delete_cookie(cookie)
except KeyError:
pass

def delete_all(self):
self.driver.cookie_jar.clear()
self.driver._cookies.clear()

def all(self, verbose=False): # NOQA: A003
cookies = {}
for cookie in self.driver.cookie_jar:
cookies[cookie.name] = cookie.value
cookies[cookie.key] = cookie.value
return cookies

def __getitem__(self, item):
cookies = {c.name: c for c in self.driver.cookie_jar}
return cookies[item].value
return self.driver.get_cookie(item).value

def __contains__(self, key):
for cookie in self.driver.cookie_jar:
if cookie.name == key:
if cookie.key == key:
return True
return False

def __eq__(self, other_object):
if isinstance(other_object, dict):
cookies_dict = {c.name: c.value for c in self.driver.cookie_jar}
cookies_dict = {c.key: c.value for c in self.driver.cookie_jar}
return cookies_dict == other_object
return False

Expand Down
4 changes: 2 additions & 2 deletions tests/test_flaskclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,8 @@ def test_cookies_extra_parameters(self):
"""Cookie can be created with extra parameters."""
timestamp = int(time.time() + 120)
self.browser.cookies.add({"sha": "zam"}, expires=timestamp)
cookie = {c.name: c for c in self.browser._browser.cookie_jar}["sha"]
assert timestamp == cookie.expires
cookie = {c.key: c for c in self.browser._browser.cookie_jar}["sha"]
assert timestamp == int(cookie.expires.timestamp())


class FlaskClientDriverTestWithCustomHeaders(unittest.TestCase):
Expand Down