Skip to content

Commit

Permalink
🎨 Reformat files
Browse files Browse the repository at this point in the history
  • Loading branch information
Ousret committed May 20, 2020
1 parent 93e1871 commit 719b6f5
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 24 deletions.
5 changes: 4 additions & 1 deletion kiss_headers/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ def parse_it(raw_headers: Any) -> Headers:
for header_name in raw_headers.raw.headers:
for header_content in raw_headers.raw.headers.getlist(header_name):
headers.append((header_name, header_content))
elif r in ["httpx._models.Response", "urllib3.response.HTTPResponse"]: # pragma: no cover
elif r in [
"httpx._models.Response",
"urllib3.response.HTTPResponse",
]: # pragma: no cover
headers = raw_headers.headers.items()

if headers is None:
Expand Down
6 changes: 5 additions & 1 deletion kiss_headers/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -639,7 +639,11 @@ def get_cookie_value(
self, cookie_name: str, __default: Optional[str] = None
) -> Optional[str]:
"""Retrieve associated value with a given cookie name."""
return str(self[cookie_name]).replace('\\"', "") if cookie_name in self else __default
return (
str(self[cookie_name]).replace('\\"', "")
if cookie_name in self
else __default
)


class SetCookie(CustomHeader):
Expand Down
4 changes: 3 additions & 1 deletion kiss_headers/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,9 @@ def pop(
elif isinstance(__index, str):
key, value = __index, self._attrs[__index] # type: ignore
else:
raise ValueError(f"Cannot pop from Header using type {type(__index)}.") # pragma: no cover
raise ValueError(
f"Cannot pop from Header using type {type(__index)}."
) # pragma: no cover

self._attrs.remove(key, __index if isinstance(__index, int) else None)
self._content = str(self._attrs)
Expand Down
27 changes: 6 additions & 21 deletions tests/test_header_operation.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,32 +122,17 @@ def test_contain_space_delimiter(self):

authorization = Header("Authorization", "Bearer mysupersecrettoken")

self.assertIn(
"Bearer",
authorization
)
self.assertIn("Bearer", authorization)

self.assertIn(
"beaRer",
authorization
)
self.assertIn("beaRer", authorization)

self.assertNotIn(
"beare",
authorization
)
self.assertNotIn("beare", authorization)

self.assertFalse(
authorization == "Bearer"
)
self.assertFalse(authorization == "Bearer")

self.assertTrue(
authorization == "bearer mysupersecrettoken"
)
self.assertTrue(authorization == "bearer mysupersecrettoken")

self.assertFalse(
authorization == "basic mysupersecrettoken"
)
self.assertFalse(authorization == "basic mysupersecrettoken")


if __name__ == "__main__":
Expand Down

0 comments on commit 719b6f5

Please sign in to comment.