From 1e3345bf8130e8cc30943c49c8b60b6edfc65794 Mon Sep 17 00:00:00 2001 From: Jonathan Levy Date: Mon, 29 Feb 2016 22:41:57 +0100 Subject: [PATCH] Add Python3 support issue3211 review19031002 --- .drone.yml | 4 ++-- CHANGELOG | 2 ++ account.py | 3 ++- invoice.py | 3 ++- party.py | 2 +- setup.py | 17 ++++++++++++++--- tests/test_account_deposit.py | 2 ++ tox.ini | 4 ++-- 8 files changed, 27 insertions(+), 10 deletions(-) diff --git a/.drone.yml b/.drone.yml index 9d7c769d8c..c4fd423e94 100644 --- a/.drone.yml +++ b/.drone.yml @@ -1,9 +1,9 @@ -image: python2.7 +image: python:all env: - POSTGRESQL_URI=postgresql://postgres@127.0.0.1:5432/ - MYSQL_URI=mysql://root@127.0.0.1:3306/ script: - pip install tox - - tox -e "py27-{sqlite,postgresql}" + - tox -e "{py27,py33,py34,py35}-{sqlite,postgresql}" --skip-missing-interpreters services: - postgres diff --git a/CHANGELOG b/CHANGELOG index ef76b2a74f..06c6095bee 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,5 @@ +* Add Python3 support + Version 3.8.0 - 2015-11-02 * Bug fixes (see mercurial logs for details) diff --git a/account.py b/account.py index 20b0294787..9cf53277d6 100644 --- a/account.py +++ b/account.py @@ -3,10 +3,10 @@ from trytond.pool import PoolMeta __all__ = ['AccountTemplate', 'Account'] -__metaclass__ = PoolMeta class AccountTemplate: + __metaclass__ = PoolMeta __name__ = 'account.account.template' @classmethod @@ -16,6 +16,7 @@ class AccountTemplate: class Account: + __metaclass__ = PoolMeta __name__ = 'account.account' @classmethod diff --git a/invoice.py b/invoice.py index f92fdfbb10..18871bc350 100644 --- a/invoice.py +++ b/invoice.py @@ -8,10 +8,10 @@ from trytond.transaction import Transaction __all__ = ['Invoice', 'InvoiceLine', 'DepositRecall', 'DepositRecallStart'] -__metaclass__ = PoolMeta class Invoice: + __metaclass__ = PoolMeta __name__ = 'account.invoice' @classmethod @@ -66,6 +66,7 @@ class Invoice: class InvoiceLine: + __metaclass__ = PoolMeta __name__ = 'account.invoice.line' @classmethod diff --git a/party.py b/party.py index 7abda31df2..f19709f5f5 100644 --- a/party.py +++ b/party.py @@ -13,10 +13,10 @@ from trytond.tools import grouped_slice, reduce_ids __all__ = ['Party'] -__metaclass__ = PoolMeta class Party: + __metaclass__ = PoolMeta __name__ = 'party.party' deposit = fields.Function(fields.Numeric('Deposit'), diff --git a/setup.py b/setup.py index 0c3a332cf1..7bbeecf3ba 100644 --- a/setup.py +++ b/setup.py @@ -5,11 +5,17 @@ from setuptools import setup import re import os -import ConfigParser +import io +try: + from configparser import ConfigParser +except ImportError: + from ConfigParser import ConfigParser def read(fname): - return open(os.path.join(os.path.dirname(__file__), fname)).read() + return io.open( + os.path.join(os.path.dirname(__file__), fname), + 'r', encoding='utf-8').read() def get_require_version(name): @@ -21,7 +27,7 @@ def get_require_version(name): major_version, minor_version + 1) return require -config = ConfigParser.ConfigParser() +config = ConfigParser() config.readfp(open('tryton.cfg')) info = dict(config.items('tryton')) for key in ('depends', 'extras_depend', 'xml'): @@ -95,6 +101,9 @@ setup(name=name, 'Natural Language :: Spanish', 'Operating System :: OS Independent', 'Programming Language :: Python :: 2.7', + 'Programming Language :: Python :: 3.3', + 'Programming Language :: Python :: 3.4', + 'Programming Language :: Python :: 3.5', 'Programming Language :: Python :: Implementation :: CPython', 'Programming Language :: Python :: Implementation :: PyPy', 'Topic :: Office/Business', @@ -111,4 +120,6 @@ setup(name=name, test_suite='tests', test_loader='trytond.test_loader:Loader', tests_require=tests_require, + use_2to3=True, + convert_2to_2_doctests=['tests/scenario_deposit.rst'], ) diff --git a/tests/test_account_deposit.py b/tests/test_account_deposit.py index ddfabaa527..2ee4446354 100644 --- a/tests/test_account_deposit.py +++ b/tests/test_account_deposit.py @@ -5,6 +5,7 @@ import doctest from trytond.tests.test_tryton import suite as test_suite from trytond.tests.test_tryton import ModuleTestCase from trytond.tests.test_tryton import doctest_setup, doctest_teardown +from trytond.tests.test_tryton import doctest_checker class AccountDepositTestCase(ModuleTestCase): @@ -18,5 +19,6 @@ def suite(): AccountDepositTestCase)) suite.addTests(doctest.DocFileSuite('scenario_deposit.rst', setUp=doctest_setup, tearDown=doctest_teardown, encoding='utf-8', + checker=doctest_checker, optionflags=doctest.REPORT_ONLY_FIRST_FAILURE)) return suite diff --git a/tox.ini b/tox.ini index e9d2876444..e2a064851d 100644 --- a/tox.ini +++ b/tox.ini @@ -1,10 +1,10 @@ [tox] -envlist = py27-{sqlite,postgresql,mysql},pypy-{sqlite,postgresql} +envlist = {py27,py33,py34,py35}-{sqlite,postgresql,mysql},pypy-{sqlite,postgresql} [testenv] commands = {envpython} setup.py test deps = - py27-postgresql: psycopg2 >= 2.0 + {py27,py33,py34,py35}-postgresql: psycopg2 >= 2.0 pypy-postgresql: psycopg2cffi >= 2.5 mysql: MySQL-python setenv =