lczub / TestLink-API-Python-client

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

Add Python 2.6 support. #21

Closed charz closed 10 years ago

charz commented 10 years ago

Hi Lczub,

I found the piece of code can't work on Python 2.6. And I do some modify. Please review it. Thanks,

Charles

lczub commented 10 years ago

Hello Charles, well I really like the code line, you want to replace. Is this the only needed change to support py26? I didn't use it currently, cause thought it would running out of PY support.

I was rather thinking about a Py3x support (in the future) than a Py26 (back porting) support (see old link http://www.findbestopensource.com/product/testlink-api-python-client)

Would it be an alternative, if we create a py26 branch to collect your changes, but not merge them into main?

Greetings Luiko

lczub commented 10 years ago

The problematic line uses a Py31 feature, back ported to Py27

charz commented 10 years ago

The patch is to avoid:

  1. pip to show error message when user install package (pip install testlink-api-python-client) in py26.
  2. Execution error in py26.

To create an alternative will be fine for me. Depend on your plan.

lczub commented 10 years ago

I will try to build up a PY26 test environment during the next week and then look, how I could integrated your patch.

charz commented 10 years ago

My environment

os: ubuntu 10.04 python: Python 2.6.5 (r265:79063, Oct 1 2012, 22:04:36) testlink: 1.9.3 (Prague)

The log of pip install

(testlink)[8:31][charz@Ivy: ~/personal] $ pip install TestLink-API-Python-client
Downloading/unpacking TestLink-API-Python-client
  Downloading TestLink-API-Python-client-0.4.7.zip (74kB): 74kB downloaded
  Running setup.py (path:/home/charz/ENV/testlink/build/TestLink-API-Python-client/setup.py) egg_info for package TestLink-API-Python-client
Installing collected packages: TestLink-API-Python-client
  Running setup.py install for TestLink-API-Python-client
    SyntaxError: ('invalid syntax', ('/home/charz/ENV/testlink/lib/python2.6/site-packages/testlink/testlinkapigeneric.py', 931, 46, '        return {nameList[x] : valueList[x] for x in range(len(nameList)) }\n'))

Successfully installed TestLink-API-Python-client
Cleaning up...

About xmlrpc problem

The problem of xmlrpclib.py in py26 is can't decode the xml data from testlink. It seem add '\n' in front of xml data. It broken the xml parsing.

Modify xmlrpclib.py

         def feed(self, data):
              print '#%s#'% data
              _data = data.strip('\n')
              print '#%s#'% _data
              self._parser.Parse(_data, 0)

Response from testlink

#
<?xml version="1.0"?>
<methodResponse>
  <params>
    <param>
      <value>
        <string> Testlink API Version: 1.0 initially written by Asiel Brumfield
 with contributions by TestLink development Team</string>
      </value>
    </param>
  </params>
</methodResponse>
#
#<?xml version="1.0"?>
<methodResponse>
  <params>
    <param>
      <value>
        <string> Testlink API Version: 1.0 initially written by Asiel Brumfield
 with contributions by TestLink development Team</string>
      </value>
    </param>
  </params>
</methodResponse>#

Hope these information can help you.

lczub commented 10 years ago

Hello Charles, I created a pre-release under https://github.com/lczub/TestLink-API-Python-client/releases/tag/v0.4.8-Beta, which should be installable under Py26 and Py27. Could you test it?

I found an additional precondition for Py26: the module argparse must be installed (see release notes).

I tested it with

Greetings Luiko

charz commented 10 years ago

Hi Luiko,

I tested pre-release v0.4.8 beta, It works fine on my environments include Py26(ubuntu 10.04) andPy27 (ubuntu 12.04).

About the testlink(1.9.3) problem, I think that should be fixed in newer version.

Thanks