Uploaded image for project: 'Nuxeo Python Client'
  1. Nuxeo Python Client
  2. NXPY-99

Fix errors in tests with Python 3.5

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.1.0
    • Fix Version/s: NoVersionApplicable
    • Component/s: None

      Description

      The client is not currently working with Python 3.5 (3.5.2 in this case, I did not try another version):

      tests/test_batchupload.py::test_cancel FAILED                            [  0%]
      tests/test_batchupload.py::test_digester[00000000000000000000000000000000-False] FAILED [  1%]
      tests/test_batchupload.py::test_digester[None-True] FAILED               [  1%]
      tests/test_batchupload.py::test_digester[-True] FAILED                   [  2%]
      tests/test_batchupload.py::test_digester[foo-True] FAILED                [  2%]
      tests/test_batchupload.py::test_execute FAILED                           [  3%]
      tests/test_batchupload.py::test_fetch FAILED                             [  3%]
      tests/test_batchupload.py::test_operation FAILED                         [  4%]
      tests/test_document.py::test_document_get_blobs FAILED                   [  5%]
      tests/test_repository.py::test_bogus_converter FAILED                    [  5%]
      tests/test_repository.py::test_convert FAILED                            [  6%]
      tests/test_repository.py::test_convert_given_converter FAILED            [  6%]
      tests/test_repository.py::test_convert_missing_args FAILED               [  7%]
      tests/test_repository.py::test_convert_unavailable FAILED                [  7%]
      tests/test_repository.py::test_convert_xpath FAILED                      [  8%]
      tests/test_repository.py::test_create_doc_and_delete FAILED              [  9%]
      tests/test_repository.py::test_fetch_acls FAILED                         [  9%]
      tests/test_repository.py::test_fetch_blob FAILED                         [ 10%]
      tests/test_repository.py::test_fetch_rendition FAILED                    [ 10%]
      tests/test_repository.py::test_fetch_renditions FAILED                   [ 11%]
      tests/test_repository.py::test_update_doc_and_delete FAILED              [ 11%]
      (others are OK)
      

      The error seems the same for all failures:

      ________________________________ test_operation ________________________________
      
      server = <nuxeo.client.Nuxeo object at 0x7f3d2ed81c50>
      
          def test_operation(server):
      >       batch = get_batch(server)
      
      server     = <nuxeo.client.Nuxeo object at 0x7f3d2ed81c50>
      
      tests/test_batchupload.py:223: 
      _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
      tests/test_batchupload.py:37: in get_batch
          batch.upload(blob)
              batch      = <Batch batchId='batchId-c44f45b9-1b5b-4f10-b802-45a3f6dc6d70', blobs={0: <BufferBlob chunkCount=0, fileIdx='0', mimety...Ids=[], uploadedSize=0>}, dropped=None, etag=None, extraInfo=None, multiPartUploadId=None, provider=None, upload_idx=0>
              blob       = <BufferBlob chunkCount=0, fileIdx=None, mimetype='application/octet-stream', name='Test.txt', size=4, uploadType='normal', uploaded='true', uploadedChunkIds=[], uploadedSize=0>
              server     = <nuxeo.client.Nuxeo object at 0x7f3d2ed81c50>
      nuxeo/models.py:197: in upload
          return self.service.upload(self, blob, **kwargs)
              blob       = <BufferBlob chunkCount=0, fileIdx=None, mimetype='application/octet-stream', name='Test.txt', size=4, uploadType='normal', uploaded='true', uploadedChunkIds=[], uploadedSize=0>
              kwargs     = {}
              self       = <Batch batchId='batchId-c44f45b9-1b5b-4f10-b802-45a3f6dc6d70', blobs={0: <BufferBlob chunkCount=0, fileIdx='0', mimety...Ids=[], uploadedSize=0>}, dropped=None, etag=None, extraInfo=None, multiPartUploadId=None, provider=None, upload_idx=0>
      nuxeo/uploads.py:232: in upload
          uploader.upload()
              batch      = <Batch batchId='batchId-c44f45b9-1b5b-4f10-b802-45a3f6dc6d70', blobs={0: <BufferBlob chunkCount=0, fileIdx='0', mimety...Ids=[], uploadedSize=0>}, dropped=None, etag=None, extraInfo=None, multiPartUploadId=None, provider=None, upload_idx=0>
              blob       = <BufferBlob chunkCount=0, fileIdx=None, mimetype='application/octet-stream', name='Test.txt', size=4, uploadType='normal', uploaded='true', uploadedChunkIds=[], uploadedSize=0>
              callback   = None
              chunk_size = 20971520
              chunked    = False
              self       = <nuxeo.uploads.API object at 0x7f3d2ed81dd8>
              uploader   = <Uploader is_complete=False, chunked=False, chunk_size=20971520, batch=<Batch batchId='batchId-c44f45b9-1b5b-4f10-b802...ion/octet-stream', name='Test.txt', size=4, uploadType='normal', uploaded='true', uploadedChunkIds=[], uploadedSize=0>>
      nuxeo/handlers/default.py:89: in upload
          self.blob.name, data, self.path, self.chunked, 0, self.headers
              data       = <_io.StringIO object at 0x7f3d2f7f8048>
              self       = <Uploader is_complete=False, chunked=False, chunk_size=20971520, batch=<Batch batchId='batchId-c44f45b9-1b5b-4f10-b802...ion/octet-stream', name='Test.txt', size=4, uploadType='normal', uploaded='true', uploadedChunkIds=[], uploadedSize=0>>
              src        = <_io.StringIO object at 0x7f3d2f7f8048>
      nuxeo/uploads.py:170: in send_data
          resource=data, path=path, raw=True, headers=headers
              __class__  = <class 'nuxeo.uploads.API'>
              chunked    = False
              data       = <_io.StringIO object at 0x7f3d2f7f8048>
              data_len   = 0
              headers    = {'Accept': 'application/json, */*', 'Cache-Control': 'no-cache', 'Content-Length': '4', 'Content-Type': 'application/octet-stream', ...}
              index      = 0
              name       = 'Test.txt'
              path       = 'batchId-c44f45b9-1b5b-4f10-b802-45a3f6dc6d70/0'
              self       = <nuxeo.uploads.API object at 0x7f3d2ed81dd8>
      nuxeo/endpoint.py:120: in post
          "POST", endpoint, data=resource, raw=raw, **kwargs
              endpoint   = 'api/v1/upload/batchId-c44f45b9-1b5b-4f10-b802-45a3f6dc6d70/0'
              kwargs     = {'headers': {'Accept': 'application/json, */*', 'Cache-Control': 'no-cache', 'Content-Length': '4', 'Content-Type': 'application/octet-stream', ...}}
              path       = 'batchId-c44f45b9-1b5b-4f10-b802-45a3f6dc6d70/0'
              raw        = True
              resource   = <_io.StringIO object at 0x7f3d2f7f8048>
              self       = <nuxeo.uploads.API object at 0x7f3d2ed81dd8>
      nuxeo/client.py:278: in request
          raise self._handle_error(exc)
              data       = <_io.StringIO object at 0x7f3d2f7f8048>
              default    = <class 'object'>
              enrichers  = None
              headers    = {'Accept': 'application/json, */*', 'Cache-Control': 'no-cache', 'Content-Length': '4', 'Content-Type': 'application/octet-stream', ...}
              kwargs     = {'timeout': (5, 30)}
              method     = 'POST'
              path       = 'api/v1/upload/batchId-c44f45b9-1b5b-4f10-b802-45a3f6dc6d70/0'
              raw        = True
              self       = NuxeoClient<host='http://localhost:8080/nuxeo/', version='11.1-SNAPSHOT'>
              url        = 'http://localhost:8080/nuxeo/api/v1/upload/batchId-c44f45b9-1b5b-4f10-b802-45a3f6dc6d70/0'
      nuxeo/client.py:273: in request
          method, url, headers=headers, auth=self.auth, data=data, **kwargs
              data       = <_io.StringIO object at 0x7f3d2f7f8048>
              default    = <class 'object'>
              enrichers  = None
              headers    = {'Accept': 'application/json, */*', 'Cache-Control': 'no-cache', 'Content-Length': '4', 'Content-Type': 'application/octet-stream', ...}
              kwargs     = {'timeout': (5, 30)}
              method     = 'POST'
              path       = 'api/v1/upload/batchId-c44f45b9-1b5b-4f10-b802-45a3f6dc6d70/0'
              raw        = True
              self       = NuxeoClient<host='http://localhost:8080/nuxeo/', version='11.1-SNAPSHOT'>
              url        = 'http://localhost:8080/nuxeo/api/v1/upload/batchId-c44f45b9-1b5b-4f10-b802-45a3f6dc6d70/0'
      .tox/py/lib/python3.5/site-packages/requests/sessions.py:530: in request
          resp = self.send(prep, **send_kwargs)
              allow_redirects = True
              auth       = ('Administrator', 'Administrator')
              cert       = None
              cookies    = None
              data       = <_io.StringIO object at 0x7f3d2f7f8048>
              files      = None
              headers    = {'Accept': 'application/json, */*', 'Cache-Control': 'no-cache', 'Content-Length': '4', 'Content-Type': 'application/octet-stream', ...}
              hooks      = None
              json       = None
              method     = 'POST'
              params     = None
              prep       = <PreparedRequest [POST]>
              proxies    = {}
              req        = <Request [POST]>
              self       = <requests.sessions.Session object at 0x7f3d2ed81cc0>
              send_kwargs = {'allow_redirects': True, 'cert': None, 'proxies': OrderedDict(), 'stream': True, ...}
              settings   = {'cert': None, 'proxies': OrderedDict(), 'stream': True, 'verify': True}
              stream     = None
              timeout    = (5, 30)
              url        = 'http://localhost:8080/nuxeo/api/v1/upload/batchId-c44f45b9-1b5b-4f10-b802-45a3f6dc6d70/0'
              verify     = None
      .tox/py/lib/python3.5/site-packages/requests/sessions.py:643: in send
          r = adapter.send(request, **kwargs)
              adapter    = <requests.adapters.HTTPAdapter object at 0x7f3d2ed818d0>
              allow_redirects = True
              hooks      = {'response': []}
              kwargs     = {'cert': None, 'proxies': OrderedDict(), 'stream': True, 'timeout': (5, 30), ...}
              request    = <PreparedRequest [POST]>
              self       = <requests.sessions.Session object at 0x7f3d2ed81cc0>
              start      = 1590423818.948962
              stream     = True
      .tox/py/lib/python3.5/site-packages/requests/adapters.py:449: in send
          timeout=timeout
              cert       = None
              chunked    = False
              conn       = <urllib3.connectionpool.HTTPConnectionPool object at 0x7f3d2ed81588>
              connect    = 5
              proxies    = OrderedDict()
              read       = 30
              request    = <PreparedRequest [POST]>
              self       = <requests.adapters.HTTPAdapter object at 0x7f3d2ed818d0>
              stream     = True
              timeout    = Timeout(connect=5, read=30, total=None)
              url        = '/nuxeo/api/v1/upload/batchId-c44f45b9-1b5b-4f10-b802-45a3f6dc6d70/0'
              verify     = True
      .tox/py/lib/python3.5/site-packages/urllib3/connectionpool.py:677: in urlopen
          chunked=chunked,
              assert_same_host = False
              body       = <_io.StringIO object at 0x7f3d2f7f8048>
              body_pos   = 0
              chunked    = False
              clean_exit = False
              conn       = None
              err        = None
              headers    = {'X-Application-Name': 'Python client', 'Cache-Control': 'no-cache', 'X-File-Type': 'application/octet-stream', 'Accep...s': 'dublincore,file', 'Authorization': 'Basic QWRtaW5pc3RyYXRvcjpBZG1pbmlzdHJhdG9y', 'Cookie': 'device=python-client'}
              is_new_proxy_conn = False
              method     = 'POST'
              pool_timeout = None
              redirect   = False
              release_conn = False
              release_this_conn = True
              response_kw = {'decode_content': False, 'preload_content': False}
              retries    = Retry(total=0, connect=None, read=False, redirect=None, status=None)
              self       = <urllib3.connectionpool.HTTPConnectionPool object at 0x7f3d2ed81588>
              timeout    = Timeout(connect=5, read=30, total=None)
              timeout_obj = Timeout(connect=5, read=30, total=None)
              url        = '/nuxeo/api/v1/upload/batchId-c44f45b9-1b5b-4f10-b802-45a3f6dc6d70/0'
      .tox/py/lib/python3.5/site-packages/urllib3/connectionpool.py:392: in _make_request
          conn.request(method, url, **httplib_request_kw)
              chunked    = False
              conn       = <urllib3.connection.HTTPConnection object at 0x7f3d2f9977f0>
              httplib_request_kw = {'body': <_io.StringIO object at 0x7f3d2f7f8048>, 'headers': {'X-Application-Name': 'Python client', 'Cache-Control': ...': 'dublincore,file', 'Authorization': 'Basic QWRtaW5pc3RyYXRvcjpBZG1pbmlzdHJhdG9y', 'Cookie': 'device=python-client'}}
              method     = 'POST'
              self       = <urllib3.connectionpool.HTTPConnectionPool object at 0x7f3d2ed81588>
              timeout    = Timeout(connect=5, read=30, total=None)
              timeout_obj = Timeout(connect=5, read=30, total=None)
              url        = '/nuxeo/api/v1/upload/batchId-c44f45b9-1b5b-4f10-b802-45a3f6dc6d70/0'
      /opt/hostedtoolcache/Python/3.5.9/x64/lib/python3.5/http/client.py:1133: in request
          self._send_request(method, url, body, headers)
              body       = <_io.StringIO object at 0x7f3d2f7f8048>
              headers    = {'X-Application-Name': 'Python client', 'Cache-Control': 'no-cache', 'X-File-Type': 'application/octet-stream', 'Accep...s': 'dublincore,file', 'Authorization': 'Basic QWRtaW5pc3RyYXRvcjpBZG1pbmlzdHJhdG9y', 'Cookie': 'device=python-client'}
              method     = 'POST'
              self       = <urllib3.connection.HTTPConnection object at 0x7f3d2f9977f0>
              url        = '/nuxeo/api/v1/upload/batchId-c44f45b9-1b5b-4f10-b802-45a3f6dc6d70/0'
      /opt/hostedtoolcache/Python/3.5.9/x64/lib/python3.5/http/client.py:1178: in _send_request
          self.endheaders(body)
              body       = <_io.StringIO object at 0x7f3d2f7f8048>
              hdr        = 'Authorization'
              header_names = {'accept': None, 'accept-encoding': None, 'authorization': None, 'cache-control': None, ...}
              headers    = {'X-Application-Name': 'Python client', 'Cache-Control': 'no-cache', 'X-File-Type': 'application/octet-stream', 'Accep...s': 'dublincore,file', 'Authorization': 'Basic QWRtaW5pc3RyYXRvcjpBZG1pbmlzdHJhdG9y', 'Cookie': 'device=python-client'}
              method     = 'POST'
              self       = <urllib3.connection.HTTPConnection object at 0x7f3d2f9977f0>
              skips      = {'skip_accept_encoding': 1}
              url        = '/nuxeo/api/v1/upload/batchId-c44f45b9-1b5b-4f10-b802-45a3f6dc6d70/0'
              value      = 'Basic QWRtaW5pc3RyYXRvcjpBZG1pbmlzdHJhdG9y'
      /opt/hostedtoolcache/Python/3.5.9/x64/lib/python3.5/http/client.py:1129: in endheaders
          self._send_output(message_body)
              message_body = <_io.StringIO object at 0x7f3d2f7f8048>
              self       = <urllib3.connection.HTTPConnection object at 0x7f3d2f9977f0>
      /opt/hostedtoolcache/Python/3.5.9/x64/lib/python3.5/http/client.py:946: in _send_output
          self.send(message_body)
              message_body = <_io.StringIO object at 0x7f3d2f7f8048>
              msg        = b'POST /nuxeo/api/v1/upload/batchId-c44f45b9-1b5b-4f10-b802-45a3f6dc6d70/0 HTTP/1.1\r\nHost: localhost:8080\r\nAccept-...: dublincore,file\r\nCookie: device=python-client\r\nAuthorization: Basic QWRtaW5pc3RyYXRvcjpBZG1pbmlzdHJhdG9y\r\n\r\n'
              self       = <urllib3.connection.HTTPConnection object at 0x7f3d2f9977f0>
      _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
      
      self = <urllib3.connection.HTTPConnection object at 0x7f3d2f9977f0>
      data = <_io.StringIO object at 0x7f3d2f7f8048>
      
          def send(self, data):
              """Send `data' to the server.
              ``data`` can be a string object, a bytes object, an array object, a
              file-like object that supports a .read() method, or an iterable object.
              """
          
              if self.sock is None:
                  if self.auto_open:
                      self.connect()
                  else:
                      raise NotConnected()
          
              if self.debuglevel > 0:
                  print("send:", repr(data))
              blocksize = 8192
              if hasattr(data, "read") :
                  if self.debuglevel > 0:
                      print("sendIng a read()able")
                  encode = False
                  try:
                      mode = data.mode
                  except AttributeError:
                      # io.BytesIO and other file-like objects don't have a `mode`
                      # attribute.
                      pass
                  else:
                      if "b" not in mode:
                          encode = True
                          if self.debuglevel > 0:
                              print("encoding file using iso-8859-1")
                  while 1:
                      datablock = data.read(blocksize)
                      if not datablock:
                          break
                      if encode:
                          datablock = datablock.encode("iso-8859-1")
      >               self.sock.sendall(datablock)
      E               TypeError: a bytes-like object is required, not 'str'
      
      blocksize  = 8192
      data       = <_io.StringIO object at 0x7f3d2f7f8048>
      datablock  = 'data'
      encode     = False
      self       = <urllib3.connection.HTTPConnection object at 0x7f3d2f9977f0>
      
      /opt/hostedtoolcache/Python/3.5.9/x64/lib/python3.5/http/client.py:915: TypeError
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                mschoentgen Mickaël Schoentgen
                Reporter:
                mschoentgen Mickaël Schoentgen
                Participants:
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 1 hour, 11 minutes
                  1h 11m