From 3ce9cf627fecfb24b9bda201b799a649e7eeae67 Mon Sep 17 00:00:00 2001 From: "Jindrich K. Smitka" Date: Mon, 22 May 2017 10:28:30 +0200 Subject: [PATCH 1/4] Fixed errors isn't concatend by default --- tests/test_xml_decoder.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/test_xml_decoder.py b/tests/test_xml_decoder.py index 7c9db015..1eaec79d 100644 --- a/tests/test_xml_decoder.py +++ b/tests/test_xml_decoder.py @@ -68,6 +68,5 @@ def test_xml_return_error_result_with_aggregate_messages(tree): ) assert is_error(rv) - messages = rv.message.split('\n') - for msg in messages: + for msg in rv.value: assert msg.find(u'Value is empty.') > -1 From 0e17094da375e42f9e234676064e19b2bfa3ff0f Mon Sep 17 00:00:00 2001 From: "Jindrich K. Smitka" Date: Mon, 22 May 2017 10:49:52 +0200 Subject: [PATCH 2/4] Fixed error message param --- tests/test_decoders.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_decoders.py b/tests/test_decoders.py index ed48cdf4..aba57d79 100644 --- a/tests/test_decoders.py +++ b/tests/test_decoders.py @@ -62,7 +62,7 @@ def ftest(val): rv = ftest(i) assert is_error(rv) - assert rv.message == 'Value is empty.' + assert rv.value == 'Value is empty.' def test_to_string_return_decoded_result(): From 4aac2a6ce8180b3e9036c971752a3dbffeeecb44 Mon Sep 17 00:00:00 2001 From: "Jindrich K. Smitka" Date: Mon, 22 May 2017 11:56:46 +0200 Subject: [PATCH 3/4] Fixed creator test --- tests/test_xml_decoder.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/test_xml_decoder.py b/tests/test_xml_decoder.py index 1eaec79d..ecc565d4 100644 --- a/tests/test_xml_decoder.py +++ b/tests/test_xml_decoder.py @@ -10,8 +10,8 @@ from pyresult import is_ok, is_error, value -def creator(*args): - return args +def creator(values): + return values @pytest.fixture @@ -42,7 +42,7 @@ def test_xml_return_ok_result(tree): ) assert is_ok(rv) - assert value(rv) == ('foo', ) + assert value(rv) == ['foo', ] def test_xml_return_error_result(tree): From 7f6aa205ffe6588ded46df90fc0c6201bbfab770 Mon Sep 17 00:00:00 2001 From: "Jindrich K. Smitka" Date: Mon, 22 May 2017 11:58:00 +0200 Subject: [PATCH 4/4] Fixed unicode handling and reduce import --- pydecoder/xmldecode.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pydecoder/xmldecode.py b/pydecoder/xmldecode.py index a6a0e14d..667156d0 100644 --- a/pydecoder/xmldecode.py +++ b/pydecoder/xmldecode.py @@ -4,7 +4,7 @@ from collections import Iterator from six import wraps, u, string_types, text_type -from six.moves import map +from six.moves import map, reduce from toolz import curry, first @@ -87,7 +87,7 @@ def to_int(val): try: return ok(int(val)) except (TypeError, ValueError) as err: - return error(unicode(err)) + return error(text_type(err)) @to_val @@ -96,7 +96,7 @@ def to_float(val): try: return ok(float(val)) except (TypeError, ValueError) as err: - return error(unicode(err)) + return error(text_type(err)) @to_val @@ -105,7 +105,7 @@ def to_string(val): if val is None: return error(u'Can\'t be null') - return ok(val) if isinstance(val, text_type) else ok(unicode(val, 'utf-8')) + return ok(val) if isinstance(val, text_type) else ok(text_type(val, 'utf-8')) @to_val