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 5aabf509f4..596b597867 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 089549d30f..89e9ae4219 100644 --- a/account.py +++ b/account.py @@ -3,10 +3,10 @@ from trytond.pool import PoolMeta __all__ = ['FiscalYear'] -__metaclass__ = PoolMeta class FiscalYear: + __metaclass__ = PoolMeta __name__ = 'account.fiscalyear' @classmethod diff --git a/invoice.py b/invoice.py index 424f8258c3..6fee43a228 100644 --- a/invoice.py +++ b/invoice.py @@ -5,10 +5,10 @@ import operator from trytond.pool import Pool, PoolMeta __all__ = ['InvoiceLine'] -__metaclass__ = PoolMeta class InvoiceLine: + __metaclass__ = PoolMeta __name__ = 'account.invoice.line' def _get_anglo_saxon_move_lines(self, amount, type_): diff --git a/product.py b/product.py index 028b703347..8cf22bff36 100644 --- a/product.py +++ b/product.py @@ -7,10 +7,10 @@ from trytond.pool import PoolMeta from trytond.modules.account_product import MissingFunction __all__ = ['Category', 'Template', 'Product'] -__metaclass__ = PoolMeta class Category: + __metaclass__ = PoolMeta __name__ = 'product.category' account_cogs = fields.Property(fields.Many2One('account.account', 'Account Cost of Goods Sold', domain=[ @@ -28,6 +28,7 @@ class Category: class Template: + __metaclass__ = PoolMeta __name__ = 'product.template' account_cogs = fields.Property(fields.Many2One('account.account', 'Account Cost of Goods Sold', domain=[ @@ -48,6 +49,7 @@ class Template: class Product: + __metaclass__ = PoolMeta __name__ = 'product.product' # Avoid raise of UserError from MissingFunction account_cogs_used = fields.Function( diff --git a/setup.py b/setup.py index 00fc35e24a..8ff5aa51d9 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'): @@ -96,6 +102,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', @@ -112,4 +121,9 @@ setup(name=name, test_suite='tests', test_loader='trytond.test_loader:Loader', tests_require=tests_require, + use_2to3=True, + convert_2to3_doctests=[ + 'tests/scenario_account_stock_anglo_saxon.rst', + 'tests/scenario_account_stock_anglo_saxon_with_drop_shipment.rst', + ], ) diff --git a/stock.py b/stock.py index 233985903b..7f883a83b3 100644 --- a/stock.py +++ b/stock.py @@ -7,7 +7,6 @@ from trytond.transaction import Transaction from trytond import backend __all__ = ['Move'] -__metaclass__ = PoolMeta def _get_field(type_): @@ -18,6 +17,7 @@ def _get_field(type_): class Move: + __metaclass__ = PoolMeta __name__ = 'stock.move' in_anglo_saxon_quantity = fields.Float('Input Anglo-Saxon Quantity', required=True) diff --git a/tests/scenario_account_stock_anglo_saxon.rst b/tests/scenario_account_stock_anglo_saxon.rst index 4f77d3c760..69e9f257ad 100644 --- a/tests/scenario_account_stock_anglo_saxon.rst +++ b/tests/scenario_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/scenario_account_stock_anglo_saxon_with_drop_shipment.rst b/tests/scenario_account_stock_anglo_saxon_with_drop_shipment.rst index 10d5783635..bbb87aa41c 100644 --- a/tests/scenario_account_stock_anglo_saxon_with_drop_shipment.rst +++ b/tests/scenario_account_stock_anglo_saxon_with_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 >>> from trytond.modules.account_stock_continental.tests.tools import \ ... add_stock_accounts diff --git a/tests/test_account_stock_anglo_saxon.py b/tests/test_account_stock_anglo_saxon.py index b5f9429517..b807afc6be 100644 --- a/tests/test_account_stock_anglo_saxon.py +++ b/tests/test_account_stock_anglo_saxon.py @@ -8,6 +8,7 @@ from mock import Mock, patch 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.pool import Pool @@ -58,9 +59,11 @@ def suite(): suite.addTests(doctest.DocFileSuite( 'scenario_account_stock_anglo_saxon.rst', setUp=doctest_setup, tearDown=doctest_teardown, encoding='utf-8', + checker=doctest_checker, optionflags=doctest.REPORT_ONLY_FIRST_FAILURE)) suite.addTests(doctest.DocFileSuite( 'scenario_account_stock_anglo_saxon_with_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 =