From 21ecb79d616f26ec8b735e58fa3b9902a7d190d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9dric=20Krier?= Date: Thu, 10 Mar 2016 00:36:31 +0100 Subject: [PATCH] Add Python3 support issue3211 --- .drone.yml | 4 ++-- CHANGELOG | 2 ++ purchase.py | 8 +++++++- sale.py | 4 +++- setup.py | 19 ++++++++++++++++--- stock.py | 3 ++- tests/__init__.py | 2 +- tests/scenario_sale_supply_drop_shipment.rst | 2 +- tests/test_sale_supply_drop_shipment.py | 2 ++ tox.ini | 4 ++-- 10 files changed, 38 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 106f5adcc6..911028ffd6 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) * Split moves into supplier and customer moves diff --git a/purchase.py b/purchase.py index 8bfab3175f..4319d348ab 100644 --- a/purchase.py +++ b/purchase.py @@ -9,10 +9,10 @@ from trytond.tools import grouped_slice __all__ = ['PurchaseRequest', 'PurchaseConfig', 'Purchase', 'PurchaseLine', 'ProductSupplier', 'CreatePurchase', 'PurchaseHandleShipmentException'] -__metaclass__ = PoolMeta class PurchaseRequest: + __metaclass__ = PoolMeta __name__ = 'purchase.request' customer = fields.Many2One('party.party', 'Customer', readonly=True, @@ -29,6 +29,7 @@ class PurchaseRequest: class PurchaseConfig: + __metaclass__ = PoolMeta __name__ = 'purchase.configuration' purchase_drop_location = fields.Property( @@ -37,6 +38,7 @@ class PurchaseConfig: class Purchase: + __metaclass__ = PoolMeta __name__ = 'purchase.purchase' customer = fields.Many2One('party.party', 'Customer', readonly=True, @@ -124,6 +126,7 @@ class Purchase: class PurchaseLine: + __metaclass__ = PoolMeta __name__ = 'purchase.line' def get_to_location(self, name): @@ -140,6 +143,7 @@ class PurchaseLine: class ProductSupplier: + __metaclass__ = PoolMeta __name__ = 'purchase.product_supplier' drop_shipment = fields.Boolean('Drop Shipment', @@ -150,6 +154,7 @@ class ProductSupplier: class CreatePurchase: + __metaclass__ = PoolMeta __name__ = 'purchase.request.create_purchase' @classmethod @@ -165,6 +170,7 @@ class CreatePurchase: class PurchaseHandleShipmentException: + __metaclass__ = PoolMeta __name__ = 'purchase.handle.shipment.exception' def transition_handle(self): diff --git a/sale.py b/sale.py index 9848943f77..e1f1a7c9e2 100644 --- a/sale.py +++ b/sale.py @@ -6,10 +6,10 @@ from trytond.pool import Pool, PoolMeta from trytond.transaction import Transaction __all__ = ['SaleConfig', 'Sale', 'SaleLine'] -__metaclass__ = PoolMeta class SaleConfig: + __metaclass__ = PoolMeta __name__ = 'sale.configuration' sale_drop_location = fields.Property( @@ -18,6 +18,7 @@ class SaleConfig: class Sale: + __metaclass__ = PoolMeta __name__ = 'sale.sale' drop_shipments = fields.Function(fields.One2Many('stock.shipment.drop', @@ -60,6 +61,7 @@ class Sale: class SaleLine: + __metaclass__ = PoolMeta __name__ = 'sale.line' @property diff --git a/setup.py b/setup.py index 17aa196ab9..65126cc1b7 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'): @@ -94,6 +100,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,8 @@ setup(name=name, test_suite='tests', test_loader='trytond.test_loader:Loader', tests_require=tests_require, + use_2to3=True, + convert_2to3_doctests=[ + 'tests/scenario_sale_supply_drop_shipment.rst', + ], ) diff --git a/stock.py b/stock.py index a8ebc93f9c..90a5f235b5 100644 --- a/stock.py +++ b/stock.py @@ -14,10 +14,10 @@ from trytond.tools import grouped_slice __all__ = ['Configuration', 'ShipmentDrop', 'Move'] -__metaclass__ = PoolMeta class Configuration: + __metaclass__ = PoolMeta __name__ = 'stock.configuration' shipment_drop_sequence = fields.Property(fields.Many2One('ir.sequence', @@ -445,6 +445,7 @@ class ShipmentDrop(Workflow, ModelSQL, ModelView): class Move: + __metaclass__ = PoolMeta __name__ = 'stock.move' customer_drop = fields.Function(fields.Many2One('party.party', diff --git a/tests/__init__.py b/tests/__init__.py index a1d8f9e98c..a3778aa82b 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_sale_supply_drop_shipment import suite +from .test_sale_supply_drop_shipment import suite __all__ = ['suite'] diff --git a/tests/scenario_sale_supply_drop_shipment.rst b/tests/scenario_sale_supply_drop_shipment.rst index 833b35b5e6..4bf9ecbb3e 100644 --- a/tests/scenario_sale_supply_drop_shipment.rst +++ b/tests/scenario_sale_supply_drop_shipment.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 >>> today = datetime.date.today() diff --git a/tests/test_sale_supply_drop_shipment.py b/tests/test_sale_supply_drop_shipment.py index bcb51b2be3..d4e90cd7d3 100644 --- a/tests/test_sale_supply_drop_shipment.py +++ b/tests/test_sale_supply_drop_shipment.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 SaleSupplyDropShipmentTestCase(ModuleTestCase): @@ -19,5 +20,6 @@ def suite(): suite.addTests(doctest.DocFileSuite( 'scenario_sale_supply_drop_shipment.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 =