You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@libcloud.apache.org by "Tomaz Muraus (JIRA)" <ji...@apache.org> on 2013/09/05 12:24:54 UTC

[jira] [Closed] (LIBCLOUD-321) libcloud.test.compute.test_deployment.DeploymentTests.test_script_file_deployment() fails with Python 3.3

     [ https://issues.apache.org/jira/browse/LIBCLOUD-321?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Tomaz Muraus closed LIBCLOUD-321.
---------------------------------

    
> libcloud.test.compute.test_deployment.DeploymentTests.test_script_file_deployment() fails with Python 3.3
> ---------------------------------------------------------------------------------------------------------
>
>                 Key: LIBCLOUD-321
>                 URL: https://issues.apache.org/jira/browse/LIBCLOUD-321
>             Project: Libcloud
>          Issue Type: Bug
>            Reporter: Arfrever Frehtes Taifersar Arahesis
>            Assignee: Tomaz Muraus
>             Fix For: 0.13.0
>
>         Attachments: libcloud.patch
>
>
> Libcloud-0.12.4 introduced libcloud.test.compute.test_deployment.DeploymentTests.test_script_file_deployment(), which fails with Python 3.3.
> {code}
> ======================================================================
> ERROR: test_script_file_deployment (libcloud.test.compute.test_deployment.DeploymentTests)
> ----------------------------------------------------------------------
> Traceback (most recent call last):
>   File "/tmp/apache-libcloud-0.12.4/libcloud/test/compute/test_deployment.py", line 126, in test_script_file_deployment
>     sfd1 = ScriptFileDeployment(script_file=file_path)
>   File "/tmp/apache-libcloud-0.12.4/libcloud/compute/deployment.py", line 193, in __init__
>     delete=delete)
>   File "/tmp/apache-libcloud-0.12.4/libcloud/compute/deployment.py", line 133, in __init__
>     argument_value=script)
>   File "/tmp/apache-libcloud-0.12.4/libcloud/compute/deployment.py", line 52, in _get_string_value
>     'object' % (argument_name))
> TypeError: script argument must be a string or a file-like object
> ----------------------------------------------------------------------
> {code}
> libcloud.utils.py3.basestring is defined as str for Python 3.
> Deployment._get_string_value() accepts argument_value, which is libcloud.utils.py3.basestring (i.e. str), but ScriptFileDeployment.\_\_init\_\_() opens a file in binary mode, so the result of reading is bytes, not str.
> Potential fix:
> {code}
> --- libcloud/compute/deployment.py
> +++ libcloud/compute/deployment.py
> @@ -185,7 +185,7 @@
>          @type delete: C{bool}
>          @keyword delete: Whether to delete the script on completion.
>          """
> -        with open(script_file, 'rb') as fp:
> +        with open(script_file, 'r') as fp:
>              content = fp.read()
>  
>          super(ScriptFileDeployment, self).__init__(script=content,
> --- libcloud/test/compute/test_deployment.py
> +++ libcloud/test/compute/test_deployment.py
> @@ -115,12 +115,8 @@
>                          client=MockClient(hostname='localhost')))
>  
>      def test_script_file_deployment(self):
> -        # TODO: Fix 3.2 compatibility
> -        if PY32:
> -            return
> -
>          file_path = os.path.abspath(__file__)
> -        with open(file_path, 'rb') as fp:
> +        with open(file_path, 'r') as fp:
>              content = fp.read()
>  
>          sfd1 = ScriptFileDeployment(script_file=file_path)
> {code}
> Alternative fix would be to open file in binary mode and (only when running with Python 3) to decode content from bytes to str.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira