diff --git a/src/zeep/xsd/types/builtins.py b/src/zeep/xsd/types/builtins.py index 5d93ef8ac..48d89889c 100644 --- a/src/zeep/xsd/types/builtins.py +++ b/src/zeep/xsd/types/builtins.py @@ -339,6 +339,8 @@ class Base64Binary(BuiltinType, AnySimpleType): @check_no_collection def xmlvalue(self, value): + if isinstance(value, six.string_types): + return value return base64.b64encode(value) def pythonvalue(self, value): diff --git a/tests/test_xsd_builtins.py b/tests/test_xsd_builtins.py index 97b22e3ef..373b70713 100644 --- a/tests/test_xsd_builtins.py +++ b/tests/test_xsd_builtins.py @@ -222,8 +222,8 @@ def test_pythonvalue(self): class TestgYear: def test_xmlvalue(self): instance = builtins.gYear() - instance.xmlvalue((2001, None)) == "2001" - instance.xmlvalue((2001, pytz.utc)) == "2001Z" + assert instance.xmlvalue((2001, None)) == "2001" + assert instance.xmlvalue((2001, pytz.utc)) == "2001Z" def test_pythonvalue(self): instance = builtins.gYear() @@ -313,6 +313,10 @@ class TestBase64Binary: def test_xmlvalue(self): instance = builtins.Base64Binary() assert instance.xmlvalue(b"hoi") == b"aG9p" + assert ( + instance.xmlvalue("aG9p") + == "aG9p" + ) def test_pythonvalue(self): instance = builtins.Base64Binary()