diff options
author | dobosevych <dobosevych@users.noreply.github.com> | 2022-04-12 15:52:41 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-12 18:52:41 +0600 |
commit | 894ddfc8b60ee615966da9fc9f97bd618e449415 (patch) | |
tree | d26660da7d9464f26a23cb78474253dc5ce5bd60 /t/unit/utils/test_json.py | |
parent | 4b67ad1692d48cb53b7caf4100a7c7957a86d163 (diff) | |
download | kombu-894ddfc8b60ee615966da9fc9f97bd618e449415.tar.gz |
Added possibility to serialize and deserialize binary messages in json (#1516)
* Added possibility to serialize and deserialize binary messages in json
* Flake8 fixed
* Hypothesis added to improve test range. Fixed issue b'\x80' serialization.
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
* Added docstring
* Fixed pylint
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Diffstat (limited to 't/unit/utils/test_json.py')
-rw-r--r-- | t/unit/utils/test_json.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/t/unit/utils/test_json.py b/t/unit/utils/test_json.py index 6af1c13b..d6a9c0b0 100644 --- a/t/unit/utils/test_json.py +++ b/t/unit/utils/test_json.py @@ -6,6 +6,8 @@ from uuid import uuid4 import pytest import pytz +from hypothesis import given, settings +from hypothesis import strategies as st from kombu.utils.encoding import str_to_bytes from kombu.utils.json import _DecodeError, dumps, loads @@ -39,6 +41,16 @@ class test_JSONEncoder: 'date': stripped.isoformat(), } + @given(message=st.binary()) + @settings(print_blob=True) + def test_binary(self, message): + serialized = loads(dumps({ + 'args': (message,), + })) + assert serialized == { + 'args': [message], + } + def test_Decimal(self): d = Decimal('3314132.13363235235324234123213213214134') assert loads(dumps({'d': d})), {'d': str(d)} |