From 94ca4de5702d5b34ab1ea5fe358cc0c992d09ec4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Fri, 11 Mar 2016 01:05:13 +0100 Subject: [PATCH] Add Python3 support issue3211 --- .drone.yml | 4 ++-- CHANGELOG | 2 ++ carrier.py | 2 +- setup.py | 21 ++++++++++++++++--- stock.py | 3 ++- tests/__init__.py | 2 +- ...chase_shipment_cost_with_account_stock.rst | 2 +- ...nt_cost_with_account_stock_anglo_saxon.rst | 2 +- tests/test_purchase_shipment_cost.py | 4 ++++ tox.ini | 4 ++-- 10 files changed, 34 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 b62ae71df4..d635c0bbfb 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/carrier.py b/carrier.py index 9561ca5bba..d0209230b3 100644 --- a/carrier.py +++ b/carrier.py @@ -4,10 +4,10 @@ from trytond.model import fields from trytond.pool import PoolMeta __all__ = ['Carrier'] -__metaclass__ = PoolMeta class Carrier: + __metaclass__ = PoolMeta __name__ = 'carrier' carrier_cost_allocation_method = fields.Selection([ ('value', 'By Value'), diff --git a/setup.py b/setup.py index 99f79882f9..b75267a506 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'): @@ -102,6 +108,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', @@ -118,4 +127,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_purchase_shipment_cost.rst', + 'tests/scenario_purchase_shipment_cost_with_account_stock.rst', + 'tests/scenario_purchase_shipment_cost_with_account_stock_anglo_saxon.rst', + ], ) diff --git a/stock.py b/stock.py index f9b2c6c463..3b1651cb3a 100644 --- a/stock.py +++ b/stock.py @@ -11,10 +11,10 @@ from trytond.transaction import Transaction from trytond.modules.product import price_digits __all__ = ['ShipmentIn', 'Move'] -__metaclass__ = PoolMeta class ShipmentIn: + __metaclass__ = PoolMeta __name__ = 'stock.shipment.in' carrier = fields.Many2One('carrier', 'Carrier', states={ 'readonly': Eval('state') != 'draft', @@ -140,6 +140,7 @@ class ShipmentIn: class Move: + __metaclass__ = PoolMeta __name__ = 'stock.move' unit_shipment_cost = fields.Numeric('Unit Shipment Cost', digits=price_digits, readonly=True) diff --git a/tests/__init__.py b/tests/__init__.py index 7facd8d4c3..4a4f987491 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -1,6 +1,6 @@ # This file is part of Tryton. The COPYRIGHT file at the top level of # this repository contains the full copyright notices and license terms. -from test_purchase_shipment_cost import suite +from .test_purchase_shipment_cost import suite __all__ = ['suite'] diff --git a/tests/scenario_purchase_shipment_cost_with_account_stock.rst b/tests/scenario_purchase_shipment_cost_with_account_stock.rst index 7e047c3bad..20f9c514e7 100644 --- a/tests/scenario_purchase_shipment_cost_with_account_stock.rst +++ b/tests/scenario_purchase_shipment_cost_with_account_stock.rst @@ -12,7 +12,7 @@ Imports:: ... get_company >>> from trytond.modules.account.tests.tools import create_fiscalyear, \ ... create_chart, get_accounts - >>> from.trytond.modules.account_invoice.tests.tools import \ + >>> from trytond.modules.account_invoice.tests.tools import \ ... set_fiscalyear_invoice_sequences >>> from trytond.modules.account_stock_continental.tests.tools import \ ... add_stock_accounts diff --git a/tests/scenario_purchase_shipment_cost_with_account_stock_anglo_saxon.rst b/tests/scenario_purchase_shipment_cost_with_account_stock_anglo_saxon.rst index f2c99926bf..f77270a0eb 100644 --- a/tests/scenario_purchase_shipment_cost_with_account_stock_anglo_saxon.rst +++ b/tests/scenario_purchase_shipment_cost_with_account_stock_anglo_saxon.rst @@ -12,7 +12,7 @@ Imports:: ... get_company >>> from trytond.modules.account.tests.tools import create_fiscalyear, \ ... create_chart, get_accounts - >>> from.trytond.modules.account_invoice.tests.tools import \ + >>> from trytond.modules.account_invoice.tests.tools import \ ... set_fiscalyear_invoice_sequences, create_payment_term >>> from trytond.modules.account_stock_continental.tests.tools import \ ... add_stock_accounts diff --git a/tests/test_purchase_shipment_cost.py b/tests/test_purchase_shipment_cost.py index e8112d6aa3..a996f8d8a5 100644 --- a/tests/test_purchase_shipment_cost.py +++ b/tests/test_purchase_shipment_cost.py @@ -6,6 +6,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 PurchaseShipmentCostTestCase(ModuleTestCase): @@ -19,13 +20,16 @@ def suite(): PurchaseShipmentCostTestCase)) suite.addTests(doctest.DocFileSuite('scenario_purchase_shipment_cost.rst', setUp=doctest_setup, tearDown=doctest_teardown, encoding='utf-8', + checker=doctest_checker, optionflags=doctest.REPORT_ONLY_FIRST_FAILURE)) suite.addTests(doctest.DocFileSuite( 'scenario_purchase_shipment_cost_with_account_stock.rst', setUp=doctest_setup, tearDown=doctest_teardown, encoding='utf-8', + checker=doctest_checker, optionflags=doctest.REPORT_ONLY_FIRST_FAILURE)) suite.addTests(doctest.DocFileSuite( 'scenario_purchase_shipment_cost_with_account_stock_anglo_saxon.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 =