Skip to content

Commit e307c96

Browse files
committed
Merge pull request #39 from sundeep-co-in/master
backport: python 2.6 support
2 parents 68a9879 + 270ee39 commit e307c96

33 files changed

+356
-308
lines changed

.travis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
language: python
22
python:
3+
- "2.6"
34
- "2.7"
45
# command to install dependencies
5-
install: "pip install -r requirements.txt"
6+
install: "pip install -r requirements-dev.txt"
67
# command to run tests
78
script: make flake8 test

CHANGELOG

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
* Wed Jan 20 2016 Sundeep Anand <[email protected]> - 1.4.2
2+
- Python 2.6 Support
3+
14
* Tue Jan 12 2016 Sundeep Anand <[email protected]> - 1.4.1
25
- Implemented zanata init (ZNTA-780)
36
- Bug ZNTA-853 - Crash when pushing local translations

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ lint-report:
2626
pylint --reports=n zanata zanataclient
2727

2828
flake8:
29-
flake8 --ignore=E501,F403,W601,F841,F401,E711,E712 zanataclient test
29+
flake8 --ignore=E501,F403,F841,F401 zanataclient test
3030

3131
test:
3232
(cd test; python test_all.py)

requirements-dev.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
-r requirements.txt
2+
flake8==2.4.1
3+
funcsigs==0.4
4+
linecache2==1.0.0
5+
mccabe==0.3.1
6+
MiniMock==1.2.8
7+
mock==1.3.0
8+
pbr==1.8.1
9+
pep8==1.5.7
10+
pyflakes==0.8.1
11+
six==1.10.0
12+
traceback2==1.4.0
13+
unittest2==1.1.0

requirements.txt

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,3 @@
1-
flake8==2.4.1
2-
funcsigs==0.4
3-
httplib2==0.9.2
4-
ipdb==0.8.1
5-
mccabe==0.3.1
6-
MiniMock==1.2.8
7-
mock==1.3.0
8-
pbr==1.8.1
9-
pep8==1.5.7
10-
polib==1.0.7
11-
pyflakes==0.8.1
12-
six==1.10.0
1+
httplib2
2+
polib
3+
ordereddict

setup.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@
77
import subprocess
88

99

10+
def read(fname):
11+
return (open(os.path.join(os.path.dirname(__file__), fname), 'rb')
12+
.read().decode('utf-8'))
13+
14+
1015
def get_client_version():
1116
number = ""
1217
path = os.path.dirname(os.path.realpath(__file__))
@@ -40,15 +45,16 @@ def get_client_version():
4045

4146
return number
4247

48+
requirements = read('requirements.txt').splitlines() + [
49+
'setuptools',
50+
]
51+
4352
setup(
4453
name="zanata-python-client",
4554
version=get_client_version(),
4655
packages=find_packages(),
4756
include_package_data=True,
48-
install_requires=[
49-
'polib',
50-
'httplib2'
51-
],
57+
install_requires=requirements,
5258
description="Zanata Python Client.",
5359
author='Jian Ni, Ding-Yi Chen, Anish Patil',
5460
@@ -77,5 +83,7 @@ def get_client_version():
7783
'License :: OSI Approved :: GNU Lesser General Public License (LGPL)',
7884
'Operating System :: Unix',
7985
'Programming Language :: Python',
86+
'Programming Language :: Python :: 2.6',
87+
'Programming Language :: Python :: 2.7',
8088
],
8189
)

test/test_context.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,11 @@ def setUp(self):
7171
self.init_context = ProjectContext(command_options, 'init')
7272

7373
def test_command_options(self):
74-
command_options_keys = ['project_type', 'comment_cols', 'user_config', 'project_config']
75-
self.assertEqual(self.context.command_options.keys(), command_options_keys)
74+
command_options_keys = ['project_type', 'project_config', 'comment_cols', 'user_config']
75+
self.assertTrue(list(self.context.command_options.keys())[0] in command_options_keys)
76+
self.assertTrue(list(self.context.command_options.keys())[1] in command_options_keys)
77+
self.assertTrue(list(self.context.command_options.keys())[2] in command_options_keys)
78+
self.assertTrue(list(self.context.command_options.keys())[3] in command_options_keys)
7679
self.assertEqual(
7780
self.context.command_dict,
7881
{'project_config': './testfiles/zanata.xml', 'comment_cols': 'en-US,es,pos,description',
@@ -94,8 +97,8 @@ def test_build_local_config(self):
9497
self.context.local_config['http_headers'],
9598
{'Accept': 'application/json', 'X-Auth-User': 'username', 'X-Auth-Token': 'key'}
9699
)
97-
self.assertIn('client_version', self.context.local_config,
98-
'local_config should contain client_version')
100+
self.assertTrue('client_version' in self.context.local_config,
101+
'local_config should contain client_version')
99102

100103
@mock.patch('zanataclient.zanatalib.projectservice.LocaleService.get_locales')
101104
@mock.patch('zanataclient.zanatalib.versionservice.VersionService.get_server_version')
@@ -163,8 +166,8 @@ def test_process_locales(self):
163166

164167
def test_init_context(self):
165168
context_data = self.init_context.get_context_data()
166-
self.assertIn('servers', context_data)
167-
self.assertIn('http://localhost:8080/zanata', context_data['servers'])
169+
self.assertTrue('servers' in context_data)
170+
self.assertTrue('http://localhost:8080/zanata' in context_data['servers'])
168171

169172
if __name__ == '__main__':
170173
unittest.main()

test/test_parseconfig.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def test_user_config(self):
4141
user_name = self.config.get_config_value("username", 'servers', server)
4242
apikey = self.config.get_config_value("key", 'servers', server)
4343
servers = self.config.get_servers()
44-
self.assertIn('http://localhost:8080/zanata', servers)
44+
self.assertTrue('http://localhost:8080/zanata' in servers)
4545
self.assertEqual(server, "local")
4646
self.assertEqual(user_name, "username")
4747
self.assertEqual(apikey, "key")

test/test_service.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,14 @@
2323
"ServiceTest",
2424
)
2525

26-
import unittest
2726
import sys
2827
import os
2928
sys.path.insert(0, os.path.abspath(__file__ + "/../.."))
3029
from zanataclient.zanatalib.service import Service
30+
if sys.version_info < (2, 7):
31+
import unittest2 as unittest
32+
else:
33+
import unittest
3134

3235

3336
# test data
@@ -66,6 +69,10 @@ def test_messages_status_201(self):
6669
result_set = self.service.messages(SERVICE_RESPONSE_201, RESPONSE_CONTENT)
6770
self.assertTrue(result_set)
6871

72+
@unittest.skipIf(
73+
sys.version_info < (2, 7),
74+
'https://docs.python.org/2/library/unittest.html#unittest.TestCase.assertRaises'
75+
)
6976
def test_messages_status_401_503(self):
7077
with self.assertRaises(SystemExit):
7178
self.service.messages(SERVICE_RESPONSE_401, RESPONSE_CONTENT)

zanataclient/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@
2020
# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
2121
# Boston, MA 02110-1301, USA.
2222

23-
from parseconfig import *
24-
from publicanutil import *
25-
from zanata import *
23+
from .parseconfig import *
24+
from .publicanutil import *
25+
from .zanata import *

0 commit comments

Comments
 (0)