-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🐛 Fix parse_it when given Mapping contains unattended types (#51)
- Loading branch information
Showing
4 changed files
with
44 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,5 +2,5 @@ | |
Expose version | ||
""" | ||
|
||
__version__ = "2.4.1" | ||
__version__ = "2.4.2" | ||
VERSION = __version__.split(".") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import unittest | ||
|
||
from kiss_headers import parse_it | ||
|
||
|
||
class UnknownMappingTest(unittest.TestCase): | ||
def test_parse_with_bytes(self): | ||
headers = parse_it({"User-Agent": b"Hello!"}) | ||
|
||
self.assertTrue("User-Agent" in headers) | ||
|
||
def test_parse_with_None(self): | ||
headers = parse_it({"User-Agent": None, "Test": "Hello!"}) | ||
|
||
self.assertTrue("User-Agent" not in headers) | ||
self.assertTrue("Test" in headers) | ||
|
||
def test_with_type_madness(self): | ||
headers = parse_it( | ||
{ | ||
"User-Agent": b"Hello!", | ||
"Age": 30, | ||
"Type": 1.554, | ||
"BeCrazy": {"pff!": "?"}, | ||
"Again": ["a", 0, 8, -1], | ||
} | ||
) | ||
|
||
self.assertTrue("User-Agent" in headers) | ||
self.assertTrue(headers.get("User-agent").content == "Hello!") | ||
self.assertTrue(headers.get("Age").content == "30") | ||
self.assertTrue(headers.get("Again").content == '["a", 0, 8, -1]') |