lczub / TestLink-API-Python-client

A Python client to use the TestLink API
104 stars 63 forks source link

uploadExecutionAttachment results in xml.parsers.expat.ExpatError: junk after document element #85

Closed roel0 closed 7 years ago

roel0 commented 7 years ago

I'm trying to upload a PNG image as attachment

fp=open("test.png")
...
tls.uploadExecutionAttachment(fp, executionid=result_id, title=os.path.basename(fp))

but this results in the following error. There is no difference if I use file path or file object

Traceback (most recent call last):
  File "update_testcase.py", line 47, in <module>
    tls.uploadExecutionAttachment(fp, executionid=result_id, title=os.path.basename(fp))
  File "C:\Python27\lib\site-packages\testlink\testlinkdecorators.py", line 168, in wrapperAddAttachment
    return methodAPI(self, *argsPositional, **argsAttachment)
  File "C:\Python27\lib\site-packages\testlink\testlinkdecorators.py", line 100, in wrapperWithArgs
    *argsPositional, **argsOptional)
  File "C:\Python27\lib\site-packages\testlink\testlinkapigeneric.py", line 1513, in callServerWithPosArgs
    response = self._callServer(methodNameAPI, argsOptional)
  File "C:\Python27\lib\site-packages\testlink\testlinkapigeneric.py", line 1731, in _callServer
    response = getattr(self.server.tl, methodNameAPI)(argsAPI)
  File "C:\Python27\lib\xmlrpclib.py", line 1240, in __call__
    return self.__send(self.__name, args)
  File "C:\Python27\lib\xmlrpclib.py", line 1599, in __request
    verbose=self.__verbose
  File "C:\Python27\lib\xmlrpclib.py", line 1280, in request
    return self.single_request(host, handler, request_body, verbose)
  File "C:\Python27\lib\xmlrpclib.py", line 1313, in single_request
    return self.parse_response(response)
  File "C:\Python27\lib\xmlrpclib.py", line 1484, in parse_response
    p.feed(data)
  File "C:\Python27\lib\xmlrpclib.py", line 558, in feed
    self._parser.Parse(data, 0)
xml.parsers.expat.ExpatError: junk after document element: line 1, column 91
roel0 commented 7 years ago

Oops, my bad.

I was using the complete dictionary returned by reportTCResult:

result_id = tls.reportTCResult(testplanid=testplan_id, status=args.result.lower()[0], testcaseid=testcase_id,
                                   buildid=build_id, notes=args.notes,
                                   user='kkk')**[0]['id']**