From 9e753691cb9fee2fcfb1ea6bcb32ebba9b2064af Mon Sep 17 00:00:00 2001 From: Jonathan Levy Date: Tue, 8 Mar 2016 12:05:20 +0100 Subject: [PATCH] Add Python3 support issue3211 review23961002 --- .drone.yml | 4 ++-- CHANGELOG | 2 ++ setup.py | 21 +++++++++++++++++--- tests/scenario_project_invoice_effort.rst | 2 +- tests/scenario_project_invoice_progress.rst | 2 +- tests/scenario_project_invoice_timesheet.rst | 2 +- tests/test_project_invoice.py | 4 ++++ timesheet.py | 2 +- tox.ini | 4 ++-- work.py | 2 +- 10 files changed, 33 insertions(+), 12 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 3f5cb014cc..a78f921569 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) * Add progress invoice method diff --git a/setup.py b/setup.py index cfe2ee8276..c7931d6cee 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', @@ -110,4 +119,10 @@ setup(name=name, test_suite='tests', test_loader='trytond.test_loader:Loader', tests_require=tests_require, + use_2to3=True, + convert_2to3_doctests=[ + 'tests/scenario_project_invoice_timesheet.rst', + 'tests/scenario_project_invoice_progress.rst', + 'tests/scenario_project_invoice_effort.rst', + ], ) diff --git a/tests/scenario_project_invoice_effort.rst b/tests/scenario_project_invoice_effort.rst index 4dd1d22b2b..9ad3fc1d64 100644 --- a/tests/scenario_project_invoice_effort.rst +++ b/tests/scenario_project_invoice_effort.rst @@ -12,7 +12,7 @@ Imports:: ... get_company >>> from trytond.modules.account.tests.tools import create_chart, \ ... get_accounts - >>> from.trytond.modules.account_invoice.tests.tools import \ + >>> from trytond.modules.account_invoice.tests.tools import \ ... create_payment_term >>> today = datetime.date.today() diff --git a/tests/scenario_project_invoice_progress.rst b/tests/scenario_project_invoice_progress.rst index 30c1c92ee7..1aa003d9f5 100644 --- a/tests/scenario_project_invoice_progress.rst +++ b/tests/scenario_project_invoice_progress.rst @@ -12,7 +12,7 @@ Imports:: ... get_company >>> from trytond.modules.account.tests.tools import create_chart, \ ... get_accounts - >>> from.trytond.modules.account_invoice.tests.tools import \ + >>> from trytond.modules.account_invoice.tests.tools import \ ... create_payment_term >>> today = datetime.date.today() diff --git a/tests/scenario_project_invoice_timesheet.rst b/tests/scenario_project_invoice_timesheet.rst index e4101b6cde..0fe65e1bb4 100644 --- a/tests/scenario_project_invoice_timesheet.rst +++ b/tests/scenario_project_invoice_timesheet.rst @@ -12,7 +12,7 @@ Imports:: ... get_company >>> from trytond.modules.account.tests.tools import create_chart, \ ... get_accounts - >>> from.trytond.modules.account_invoice.tests.tools import \ + >>> from trytond.modules.account_invoice.tests.tools import \ ... create_payment_term >>> today = datetime.date.today() diff --git a/tests/test_project_invoice.py b/tests/test_project_invoice.py index 9b259c9a60..66a03a19e8 100644 --- a/tests/test_project_invoice.py +++ b/tests/test_project_invoice.py @@ -5,6 +5,7 @@ import doctest import trytond.tests.test_tryton 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 ProjectInvoiceTestCase(ModuleTestCase): @@ -19,13 +20,16 @@ def suite(): suite.addTests(doctest.DocFileSuite( 'scenario_project_invoice_timesheet.rst', setUp=doctest_setup, tearDown=doctest_teardown, encoding='utf-8', + checker=doctest_checker, optionflags=doctest.REPORT_ONLY_FIRST_FAILURE)) suite.addTests(doctest.DocFileSuite( 'scenario_project_invoice_effort.rst', setUp=doctest_setup, tearDown=doctest_teardown, encoding='utf-8', + checker=doctest_checker, optionflags=doctest.REPORT_ONLY_FIRST_FAILURE)) suite.addTests(doctest.DocFileSuite( 'scenario_project_invoice_progress.rst', setUp=doctest_setup, tearDown=doctest_teardown, encoding='utf-8', + checker=doctest_checker, optionflags=doctest.REPORT_ONLY_FIRST_FAILURE)) return suite diff --git a/timesheet.py b/timesheet.py index bbf6cc37ff..4eda487be4 100644 --- a/timesheet.py +++ b/timesheet.py @@ -5,10 +5,10 @@ from trytond.pool import PoolMeta __all__ = ['TimesheetLine'] -__metaclass__ = PoolMeta class TimesheetLine: + __metaclass__ = PoolMeta __name__ = 'timesheet.line' invoice_line = fields.Many2One('account.invoice.line', 'Invoice Line', readonly=True) 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 = diff --git a/work.py b/work.py index 7139870d54..4b2333c7e8 100644 --- a/work.py +++ b/work.py @@ -20,7 +20,6 @@ from trytond.tools import reduce_ids, grouped_slice __all__ = ['Work', 'WorkInvoicedProgress', 'OpenInvoice'] -__metaclass__ = PoolMeta INVOICE_METHODS = [ ('manual', 'Manual'), @@ -31,6 +30,7 @@ INVOICE_METHODS = [ class Work: + __metaclass__ = PoolMeta __name__ = 'project.work' project_invoice_method = fields.Selection(INVOICE_METHODS, 'Invoice Method',