From be3a34a8fb065b116fbb29014b682fdb7e468830 Mon Sep 17 00:00:00 2001 From: Jonathan Levy Date: Sat, 27 Feb 2016 00:34:46 +0100 Subject: [PATCH] Add Python3 support issue3211 review17851002 --- .drone.yml | 4 ++-- CHANGELOG | 2 ++ product.py | 3 ++- setup.py | 17 ++++++++++++++--- stock.py | 8 +++++++- tests/test_stock_lot.py | 2 ++ tox.ini | 4 ++-- 7 files changed, 31 insertions(+), 9 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 0ce2542a12..98280955f4 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) * Adapt inventory to use grouping diff --git a/product.py b/product.py index 3061e6dca1..90b11c146d 100644 --- a/product.py +++ b/product.py @@ -5,10 +5,10 @@ from trytond.pyson import Eval from trytond.pool import PoolMeta __all__ = ['Template', 'Product', 'TemplateLotType'] -__metaclass__ = PoolMeta class Template: + __metaclass__ = PoolMeta __name__ = 'product.template' # TODO to replace with a Multiple Selection @@ -22,6 +22,7 @@ class Template: class Product: + __metaclass__ = PoolMeta __name__ = 'product.product' def lot_is_required(self, from_, to): diff --git a/setup.py b/setup.py index 242b35aaf5..434012b0f3 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,6 @@ setup(name=name, test_suite='tests', test_loader='trytond.test_loader:Loader', tests_require=tests_require, + use_2to3=True, + convert_2to3_doctests=['tests/scenario_stock_lot_shipment_out.rst'], ) diff --git a/stock.py b/stock.py index 1a0f85f0c5..d1aed4bacb 100644 --- a/stock.py +++ b/stock.py @@ -10,7 +10,6 @@ __all__ = ['Lot', 'LotType', 'Move', 'ShipmentIn', 'ShipmentOut', 'ShipmentOutReturn', 'Period', 'PeriodCacheLot', 'Inventory', 'InventoryLine'] -__metaclass__ = PoolMeta class Lot(ModelSQL, ModelView, StockMixin): @@ -46,6 +45,7 @@ class LotType(ModelSQL, ModelView): class Move: + __metaclass__ = PoolMeta __name__ = 'stock.move' lot = fields.Many2One('stock.lot', 'Lot', domain=[ @@ -80,6 +80,7 @@ class Move: class ShipmentIn: + __metaclass__ = PoolMeta __name__ = 'stock.shipment.in' @classmethod @@ -91,6 +92,7 @@ class ShipmentIn: class ShipmentOut: + __metaclass__ = PoolMeta __name__ = 'stock.shipment.out' @classmethod @@ -131,6 +133,7 @@ class ShipmentOut: class ShipmentOutReturn: + __metaclass__ = PoolMeta __name__ = 'stock.shipment.out.return' @classmethod @@ -143,6 +146,7 @@ class ShipmentOutReturn: class Period: + __metaclass__ = PoolMeta __name__ = 'stock.period' lot_caches = fields.One2Many('stock.period.cache.lot', 'period', 'Lot Caches', readonly=True) @@ -179,6 +183,7 @@ class PeriodCacheLot(ModelSQL, ModelView): class Inventory: + __metaclass__ = PoolMeta __name__ = 'stock.inventory' @classmethod @@ -187,6 +192,7 @@ class Inventory: class InventoryLine: + __metaclass__ = PoolMeta __name__ = 'stock.inventory.line' lot = fields.Many2One('stock.lot', 'Lot', domain=[ diff --git a/tests/test_stock_lot.py b/tests/test_stock_lot.py index bfeacdaa17..78f466a06a 100644 --- a/tests/test_stock_lot.py +++ b/tests/test_stock_lot.py @@ -9,6 +9,7 @@ from decimal import Decimal import trytond.tests.test_tryton from trytond.tests.test_tryton import ModuleTestCase, with_transaction from trytond.tests.test_tryton import doctest_setup, doctest_teardown +from trytond.tests.test_tryton import doctest_checker from trytond.transaction import Transaction from trytond.pool import Pool @@ -228,5 +229,6 @@ def suite(): StockLotTestCase)) suite.addTests(doctest.DocFileSuite('scenario_stock_lot_shipment_out.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 =