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

feat(matcher): Allow bytes type in from_term function #281

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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions pact/matchers.py
Expand Up @@ -184,13 +184,13 @@ def from_term(term):
Parse the provided term into the JSON for the mock service.

:param term: The term to be parsed.
:type term: None, list, dict, int, float, str, unicode, Matcher
:type term: None, list, dict, int, float, str, bytes, unicode, Matcher
:return: The JSON representation for this term.
:rtype: dict, list, str
"""
if term is None:
return term
elif isinstance(term, (six.string_types, int, float)):
elif isinstance(term, (six.string_types, six.binary_type, int, float)):
return term
elif isinstance(term, dict):
return {k: from_term(v) for k, v in term.items()}
Expand Down
3 changes: 3 additions & 0 deletions tests/test_matchers.py
Expand Up @@ -135,6 +135,9 @@ def test_int(self):
def test_float(self):
self.assertEqual(from_term(3.14), 3.14)

def test_bytes(self):
self.assertEqual(from_term(b'testing'), b'testing')

def test_list(self):
term = [1, 123, 'sample']
self.assertEqual(from_term(term), term)
Expand Down