From 06b3026bcdf483aff12f1daa8b6d26d9801ace61 Mon Sep 17 00:00:00 2001 From: Leonardo Rochael Almeida <leorochael@gmail.com> Date: Wed, 3 Jun 2015 06:15:44 +0200 Subject: [PATCH] [IMP] unittest2 > unittest The `unittest2` package is simply a backport of `unittest` from the Standard Library of Python 2.7 to previous versions. There is no reason to use it any longer. Closes #6941 --- addons/account/tests/test_reconciliation.py | 4 ++-- addons/sale/tests/test_product_id_change.py | 4 ++-- addons/web/tests/test_menu.py | 4 ++-- addons/web/tests/test_serving_base.py | 4 ++-- addons/web_editor/tests/test_converter.py | 4 ++-- addons/website/tests/test_converter.py | 7 +++---- addons/website/tests/test_views.py | 4 ++-- debian/control | 1 - doc/reference/javascript.rst | 7 ------- doc/reference/testing.rst | 3 +-- openerp/addons/base/tests/test_acl.py | 4 ++-- openerp/addons/base/tests/test_base.py | 10 +++++----- openerp/addons/base/tests/test_basecase.py | 4 ++-- openerp/addons/base/tests/test_db_cursor.py | 4 ++-- openerp/addons/base/tests/test_expression.py | 4 ++-- openerp/addons/base/tests/test_func.py | 4 ++-- openerp/addons/base/tests/test_ir_actions.py | 4 ++-- openerp/addons/base/tests/test_ir_sequence.py | 12 ++++++------ .../base/tests/test_ir_sequence_date_range.py | 4 ++-- openerp/addons/base/tests/test_ir_values.py | 4 ++-- openerp/addons/base/tests/test_mail.py | 12 ++++++------ openerp/addons/base/tests/test_misc.py | 6 +++--- openerp/addons/base/tests/test_res_config.py | 2 +- openerp/addons/base/tests/test_res_lang.py | 2 +- openerp/addons/base/tests/test_search.py | 4 ++-- openerp/addons/base/tests/test_uninstall.py | 6 +++--- openerp/addons/base/tests/test_view_validation.py | 6 +++--- openerp/addons/base/tests/test_views.py | 2 +- openerp/addons/test_convert/tests/test_convert.py | 6 +++--- openerp/addons/test_impex/tests/test_load.py | 2 +- openerp/modules/module.py | 14 +++++++------- openerp/service/server.py | 8 ++++---- openerp/tests/common.py | 8 ++++---- openerp/tools/assertion_report.py | 2 +- requirements.txt | 1 - setup.cfg | 1 - setup.py | 2 -- setup/package.dfcentos | 1 - setup/package.dfdebian | 1 - 39 files changed, 83 insertions(+), 99 deletions(-) diff --git a/addons/account/tests/test_reconciliation.py b/addons/account/tests/test_reconciliation.py index a11987dae075..73b42c102cb8 100644 --- a/addons/account/tests/test_reconciliation.py +++ b/addons/account/tests/test_reconciliation.py @@ -1,6 +1,6 @@ from openerp.addons.account.tests.account_test_classes import AccountingTestCase import time -import unittest2 +import unittest class TestReconciliation(AccountingTestCase): @@ -209,7 +209,7 @@ class TestReconciliation(AccountingTestCase): self.account_rcv.id: {'debit': 42.0, 'credit': 0.0, 'amount_currency': 50, 'currency_id': self.currency_swiss_id}, }) - @unittest2.skip('adapt to new accounting') + @unittest.skip('adapt to new accounting') def test_balanced_exchanges_gain_loss(self): # The point of this test is to show that we handle correctly the gain/loss exchanges during reconciliations in foreign currencies. # For instance, with a company set in EUR, and a USD rate set to 0.033, diff --git a/addons/sale/tests/test_product_id_change.py b/addons/sale/tests/test_product_id_change.py index e6cb0267a172..fd53b431235c 100644 --- a/addons/sale/tests/test_product_id_change.py +++ b/addons/sale/tests/test_product_id_change.py @@ -1,4 +1,4 @@ -import unittest2 +import unittest from openerp.tests.common import TransactionCase class TestProductIdChange(TransactionCase): @@ -17,7 +17,7 @@ class TestProductIdChange(TransactionCase): self.product_model = self.registry('product.product') self.so_line_model = self.registry('sale.order.line') - @unittest2.skip(""" + @unittest.skip(""" Due to `sale` rewrite (94716a3f14d929574c46ef165e4364d12a5903ed), the commit 503820acb6d82a85c0c49ac26f7e7f8cd73851dd has been partially ignored during the forward-port to master and need to be rewritten using new-api. diff --git a/addons/web/tests/test_menu.py b/addons/web/tests/test_menu.py index d0674d247d51..c85684bdf846 100644 --- a/addons/web/tests/test_menu.py +++ b/addons/web/tests/test_menu.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- -import unittest2 +import unittest from ..controllers import main -class ActionMungerTest(unittest2.TestCase): +class ActionMungerTest(unittest.TestCase): def test_actual_treeview(self): action = { "views": [[False, "tree"], [False, "form"], diff --git a/addons/web/tests/test_serving_base.py b/addons/web/tests/test_serving_base.py index 10545a3efb45..e9689fcb1e33 100644 --- a/addons/web/tests/test_serving_base.py +++ b/addons/web/tests/test_serving_base.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- import random -import unittest2 +import unittest from openerp.tools import topological_sort @@ -10,7 +10,7 @@ def sample(population): population, random.randint(0, min(len(population), 5))) -class TestModulesLoading(unittest2.TestCase): +class TestModulesLoading(unittest.TestCase): def setUp(self): self.mods = map(str, range(1000)) def test_topological_sort(self): diff --git a/addons/web_editor/tests/test_converter.py b/addons/web_editor/tests/test_converter.py index ec8124b66b59..48a157c5d17d 100644 --- a/addons/web_editor/tests/test_converter.py +++ b/addons/web_editor/tests/test_converter.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- import textwrap -import unittest2 +import unittest from lxml import etree, html from lxml.builder import E @@ -10,7 +10,7 @@ from openerp.addons.base.ir import ir_qweb from openerp.addons.web_editor.models.ir_qweb import html_to_text -class TestHTMLToText(unittest2.TestCase): +class TestHTMLToText(unittest.TestCase): def test_rawstring(self): self.assertEqual( "foobar", diff --git a/addons/website/tests/test_converter.py b/addons/website/tests/test_converter.py index ba60e2fac95d..2644a838dfc4 100644 --- a/addons/website/tests/test_converter.py +++ b/addons/website/tests/test_converter.py @@ -1,9 +1,8 @@ # -*- coding: utf-8 -*- -import unittest2 +import unittest from openerp.addons.website.models.website import slugify, unslug - -class TestUnslug(unittest2.TestCase): +class TestUnslug(unittest.TestCase): def test_unslug(self): tests = { '': (None, None), @@ -24,7 +23,7 @@ class TestUnslug(unittest2.TestCase): self.assertEqual(unslug(slug), expected) -class TestTitleToSlug(unittest2.TestCase): +class TestTitleToSlug(unittest.TestCase): """ Those tests should pass with or without python-slugify See website/models/website.py slugify method diff --git a/addons/website/tests/test_views.py b/addons/website/tests/test_views.py index b63ac75997dc..9ab3e77c9875 100644 --- a/addons/website/tests/test_views.py +++ b/addons/website/tests/test_views.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- import itertools -import unittest2 +import unittest from lxml import etree as ET, html from lxml.html import builder as h @@ -61,7 +61,7 @@ class TestViewSaving(common.TransactionCase): company = self.registry('res.company').browse(self.cr, self.uid, 1) self.assertEqual(company.phone, "+00 00 000 00 0 000") - @unittest2.skip("save conflict for embedded (saved by third party or previous version in page) not implemented") + @unittest.skip("save conflict for embedded (saved by third party or previous version in page) not implemented") def test_embedded_conflict(self): e1 = h.SPAN("My Company", attrs(model='res.company', id=1, field='name')) e2 = h.SPAN("Leeroy Jenkins", attrs(model='res.company', id=1, field='name')) diff --git a/debian/control b/debian/control index 1b1c9d5531fe..75e40dfe59d5 100644 --- a/debian/control +++ b/debian/control @@ -44,7 +44,6 @@ Depends: python-simplejson, python-suds, python-tz, - python-unittest2, python-vatnumber, python-vobject, python-werkzeug, diff --git a/doc/reference/javascript.rst b/doc/reference/javascript.rst index 609fe58d3d94..d7dd2f70b709 100644 --- a/doc/reference/javascript.rst +++ b/doc/reference/javascript.rst @@ -1330,11 +1330,6 @@ command-line (or in a CI system), but while actually running it is pretty simple the setup of the pre-requisite parts has some complexities. -#. Install unittest2_ in your Python environment. Both - can trivially be installed via `pip <http://pip-installer.org>`_ or - `easy_install - <http://packages.python.org/distribute/easy_install.html>`_. - #. Install PhantomJS_. It is a headless browser which allows automating running and testing web pages. QUnitSuite_ uses it to actually run the qunit_ test suite. @@ -1402,8 +1397,6 @@ the OpenERP Web test suite. .. _qunit assertions: http://api.qunitjs.com/category/assert/ -.. _unittest2: http://pypi.python.org/pypi/unittest2 - .. _QUnitSuite: http://pypi.python.org/pypi/QUnitSuite/ .. _PhantomJS: http://phantomjs.org/ diff --git a/doc/reference/testing.rst b/doc/reference/testing.rst index 9523d732e0ff..53690426103a 100644 --- a/doc/reference/testing.rst +++ b/doc/reference/testing.rst @@ -7,7 +7,7 @@ Testing Modules =============== -Odoo provides support for testing modules using unittest2_. +Odoo provides support for testing modules using unittest. To write tests, simply define a ``tests`` sub-package in your module, it will be automatically inspected for test modules. Test modules should have a name @@ -80,5 +80,4 @@ Odoo server. As of Odoo 8, running tests outside of the install/update cycle is not supported. -.. _unittest2: http://pypi.python.org/pypi/unittest2 .. _unittest documentation: https://docs.python.org/2/library/unittest.html diff --git a/openerp/addons/base/tests/test_acl.py b/openerp/addons/base/tests/test_acl.py index b003a2041565..635359c251e1 100644 --- a/openerp/addons/base/tests/test_acl.py +++ b/openerp/addons/base/tests/test_acl.py @@ -1,4 +1,4 @@ -import unittest2 +import unittest from lxml import etree from openerp.exceptions import AccessError @@ -165,4 +165,4 @@ class TestACL(common.TransactionCase): self.erp_manager_group.write({'users': [(3, self.demo_uid)]}) if __name__ == '__main__': - unittest2.main() + unittest.main() diff --git a/openerp/addons/base/tests/test_base.py b/openerp/addons/base/tests/test_base.py index 0522595872fd..11351a805177 100644 --- a/openerp/addons/base/tests/test_base.py +++ b/openerp/addons/base/tests/test_base.py @@ -1,4 +1,4 @@ -import unittest2 +import unittest import openerp.tests.common as common from openerp.exceptions import ValidationError @@ -474,7 +474,7 @@ def tearDownModule(): global test_state test_state = None -class TestPhaseInstall00(unittest2.TestCase): +class TestPhaseInstall00(unittest.TestCase): """ WARNING: Relies on tests being run in alphabetical order """ @@ -494,7 +494,7 @@ class TestPhaseInstall00(unittest2.TestCase): self.state, 'init', "Testcase state should not have been transitioned from 00") -class TestPhaseInstall01(unittest2.TestCase): +class TestPhaseInstall01(unittest.TestCase): at_install = False def test_default_norun(self): @@ -504,7 +504,7 @@ class TestPhaseInstall01(unittest2.TestCase): def test_set_run(self): test_state['set_at_install'] = True -class TestPhaseInstall02(unittest2.TestCase): +class TestPhaseInstall02(unittest.TestCase): """ Can't put the check for test_set_run in the same class: if @common.at_install does not work for test_set_run, it won't work for @@ -520,4 +520,4 @@ class TestPhaseInstall02(unittest2.TestCase): "The flag should be set if local overriding of runstate") if __name__ == '__main__': - unittest2.main() + unittest.main() diff --git a/openerp/addons/base/tests/test_basecase.py b/openerp/addons/base/tests/test_basecase.py index eb29308f5a81..42b47749bf70 100644 --- a/openerp/addons/base/tests/test_basecase.py +++ b/openerp/addons/base/tests/test_basecase.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -import unittest2 +import unittest from openerp.tests import common @@ -83,4 +83,4 @@ class test_transaction_case(common.TransactionCase): self.assertEqual(partner, p_browse_ref, "browse_ref() should resolve xid to browse records") if __name__ == '__main__': - unittest2.main() + unittest.main() diff --git a/openerp/addons/base/tests/test_db_cursor.py b/openerp/addons/base/tests/test_db_cursor.py index b4c5f3152c25..9fa61493f990 100644 --- a/openerp/addons/base/tests/test_db_cursor.py +++ b/openerp/addons/base/tests/test_db_cursor.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -import unittest2 +import unittest import openerp from openerp.tools.misc import mute_logger @@ -12,7 +12,7 @@ def registry(): return openerp.modules.registry.RegistryManager.get(common.get_db_name()) -class test_cr_execute(unittest2.TestCase): +class test_cr_execute(unittest.TestCase): """ Try cr.execute with wrong parameters """ @mute_logger('openerp.sql_db') diff --git a/openerp/addons/base/tests/test_expression.py b/openerp/addons/base/tests/test_expression.py index ac336f334e01..4bf112da1a92 100644 --- a/openerp/addons/base/tests/test_expression.py +++ b/openerp/addons/base/tests/test_expression.py @@ -1,4 +1,4 @@ -import unittest2 +import unittest import openerp from openerp.osv.expression import get_unaccent_wrapper @@ -521,4 +521,4 @@ class test_expression(common.TransactionCase): self.env['res.users'].search([('name', '=', 'test')]) if __name__ == '__main__': - unittest2.main() + unittest.main() diff --git a/openerp/addons/base/tests/test_func.py b/openerp/addons/base/tests/test_func.py index 6d9db8d04e3e..d50b555265e4 100644 --- a/openerp/addons/base/tests/test_func.py +++ b/openerp/addons/base/tests/test_func.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- import functools -import unittest2 +import unittest from openerp.tools.func import compose -class TestCompose(unittest2.TestCase): +class TestCompose(unittest.TestCase): def test_basic(self): str_add = compose(str, lambda a, b: a + b) self.assertEqual( diff --git a/openerp/addons/base/tests/test_ir_actions.py b/openerp/addons/base/tests/test_ir_actions.py index 0d1212a8e57d..ee494ad84a7f 100644 --- a/openerp/addons/base/tests/test_ir_actions.py +++ b/openerp/addons/base/tests/test_ir_actions.py @@ -1,4 +1,4 @@ -import unittest2 +import unittest from openerp.exceptions import ValidationError import openerp.tests.common as common @@ -403,4 +403,4 @@ workflow""" if __name__ == '__main__': - unittest2.main() + unittest.main() diff --git a/openerp/addons/base/tests/test_ir_sequence.py b/openerp/addons/base/tests/test_ir_sequence.py index 4d13ce6bd4a7..3d2f891c63ec 100644 --- a/openerp/addons/base/tests/test_ir_sequence.py +++ b/openerp/addons/base/tests/test_ir_sequence.py @@ -9,7 +9,7 @@ # This assume an existing database. import psycopg2 import psycopg2.errorcodes -import unittest2 +import unittest import openerp from openerp.tests import common @@ -31,7 +31,7 @@ def drop_sequence(code): cr.commit() cr.close() -class test_ir_sequence_standard(unittest2.TestCase): +class test_ir_sequence_standard(unittest.TestCase): """ A few tests for a 'Standard' (i.e. PostgreSQL) sequence. """ def test_ir_sequence_create(self): @@ -76,7 +76,7 @@ class test_ir_sequence_standard(unittest2.TestCase): def tearDownClass(cls): drop_sequence('test_sequence_type') -class test_ir_sequence_no_gap(unittest2.TestCase): +class test_ir_sequence_no_gap(unittest.TestCase): """ Copy of the previous tests for a 'No gap' sequence. """ def test_ir_sequence_create_no_gap(self): @@ -116,7 +116,7 @@ class test_ir_sequence_no_gap(unittest2.TestCase): def tearDownClass(cls): drop_sequence('test_sequence_type_2') -class test_ir_sequence_change_implementation(unittest2.TestCase): +class test_ir_sequence_change_implementation(unittest.TestCase): """ Create sequence objects and change their ``implementation`` field. """ def test_ir_sequence_1_create(self): @@ -156,7 +156,7 @@ class test_ir_sequence_change_implementation(unittest2.TestCase): drop_sequence('test_sequence_type_3') drop_sequence('test_sequence_type_4') -class test_ir_sequence_generate(unittest2.TestCase): +class test_ir_sequence_generate(unittest.TestCase): """ Create sequence objects and generate some values. """ def test_ir_sequence_create(self): @@ -224,4 +224,4 @@ class Test_ir_sequence_init(common.TransactionCase): assert read_sequence == "0001", 'The actual sequence value must be 1. reading : %s' % read_sequence if __name__ == "__main__": - unittest2.main() + unittest.main() diff --git a/openerp/addons/base/tests/test_ir_sequence_date_range.py b/openerp/addons/base/tests/test_ir_sequence_date_range.py index 6c4af6902218..c2ddc4e4f0fe 100644 --- a/openerp/addons/base/tests/test_ir_sequence_date_range.py +++ b/openerp/addons/base/tests/test_ir_sequence_date_range.py @@ -1,4 +1,4 @@ -import unittest2 +import unittest from openerp.tests import common from datetime import date @@ -119,4 +119,4 @@ class test_ir_sequence_date_range_change_implementation(common.SingleTransaction if __name__ == '__main__': - unittest2.main() + unittest.main() diff --git a/openerp/addons/base/tests/test_ir_values.py b/openerp/addons/base/tests/test_ir_values.py index c59f93a2db09..435421ea845c 100644 --- a/openerp/addons/base/tests/test_ir_values.py +++ b/openerp/addons/base/tests/test_ir_values.py @@ -1,4 +1,4 @@ -import unittest2 +import unittest import openerp.tests.common as common @@ -95,4 +95,4 @@ class test_ir_values(common.TransactionCase): assert isinstance(actions[0][2], dict) and actions[0][2]['id'] == report_id, 'Bound action does not match definition' if __name__ == '__main__': - unittest2.main() + unittest.main() diff --git a/openerp/addons/base/tests/test_mail.py b/openerp/addons/base/tests/test_mail.py index 982a18f329e0..ec9877f895dd 100644 --- a/openerp/addons/base/tests/test_mail.py +++ b/openerp/addons/base/tests/test_mail.py @@ -4,13 +4,13 @@ # > PYTHONPATH=. python2 openerp/tests/test_misc.py # Part of Odoo. See LICENSE file for full copyright and licensing details. -import unittest2 +import unittest from openerp.tools import html_sanitize, html_email_clean, append_content_to_html, plaintext2html, email_split import test_mail_examples -class TestSanitizer(unittest2.TestCase): +class TestSanitizer(unittest.TestCase): """ Test the html sanitizer that filters html to remove unwanted attributes """ def test_basic_sanitizer(self): @@ -111,7 +111,7 @@ class TestSanitizer(unittest2.TestCase): self.assertNotIn('</body></html>', html, 'html_sanitize did not remove extra closing tags') -class TestCleaner(unittest2.TestCase): +class TestCleaner(unittest.TestCase): """ Test the email cleaner function that filters the content of incoming emails """ def test_00_basic_text(self): @@ -340,7 +340,7 @@ class TestCleaner(unittest2.TestCase): self.assertNotIn('encoding', new_html, 'html_email_cleaner did not remove correctly encoding attributes') -class TestHtmlTools(unittest2.TestCase): +class TestHtmlTools(unittest.TestCase): """ Test some of our generic utility functions about html """ def test_plaintext2html(self): @@ -367,7 +367,7 @@ class TestHtmlTools(unittest2.TestCase): self.assertEqual(append_content_to_html(html, content, plaintext_flag, preserve_flag, container_tag), expected, 'append_content_to_html is broken') -class TestEmailTools(unittest2.TestCase): +class TestEmailTools(unittest.TestCase): """ Test some of our generic utility functions for emails """ def test_email_split(self): @@ -382,4 +382,4 @@ class TestEmailTools(unittest2.TestCase): self.assertEqual(email_split(text), expected, 'email_split is broken') if __name__ == '__main__': - unittest2.main() + unittest.main() diff --git a/openerp/addons/base/tests/test_misc.py b/openerp/addons/base/tests/test_misc.py index 11cc3f49638b..d20a17403ff9 100644 --- a/openerp/addons/base/tests/test_misc.py +++ b/openerp/addons/base/tests/test_misc.py @@ -1,9 +1,9 @@ -import unittest2 +import unittest from openerp.tools import misc -class test_countingstream(unittest2.TestCase): +class test_countingstream(unittest.TestCase): def test_empty_stream(self): s = misc.CountingStream(iter([])) self.assertEqual(s.index, -1) @@ -34,4 +34,4 @@ class test_countingstream(unittest2.TestCase): self.assertEqual(s.index, 0) if __name__ == '__main__': - unittest2.main() + unittest.main() diff --git a/openerp/addons/base/tests/test_res_config.py b/openerp/addons/base/tests/test_res_config.py index 450925a522c7..0a6a49efdeb6 100644 --- a/openerp/addons/base/tests/test_res_config.py +++ b/openerp/addons/base/tests/test_res_config.py @@ -1,4 +1,4 @@ -import unittest2 +import unittest import openerp import openerp.tests.common as common diff --git a/openerp/addons/base/tests/test_res_lang.py b/openerp/addons/base/tests/test_res_lang.py index 368ce7101582..c7e591472c53 100644 --- a/openerp/addons/base/tests/test_res_lang.py +++ b/openerp/addons/base/tests/test_res_lang.py @@ -1,4 +1,4 @@ -import unittest2 +import unittest import openerp.tests.common as common diff --git a/openerp/addons/base/tests/test_search.py b/openerp/addons/base/tests/test_search.py index 32f6f93d95ba..000f05a33d81 100644 --- a/openerp/addons/base/tests/test_search.py +++ b/openerp/addons/base/tests/test_search.py @@ -1,4 +1,4 @@ -import unittest2 +import unittest import openerp.tests.common as common @@ -161,4 +161,4 @@ class test_search(common.TransactionCase): self.assertEqual(search_result, expected_order) if __name__ == '__main__': - unittest2.main() + unittest.main() diff --git a/openerp/addons/base/tests/test_uninstall.py b/openerp/addons/base/tests/test_uninstall.py index 233ffe97ce06..8bb658d61ba1 100644 --- a/openerp/addons/base/tests/test_uninstall.py +++ b/openerp/addons/base/tests/test_uninstall.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- # This assumes an existing but uninitialized database. -import unittest2 +import unittest import openerp from openerp import SUPERUSER_ID @@ -51,7 +51,7 @@ def uninstall_module(module_name): cr.close() reload_registry() -class test_uninstall(unittest2.TestCase): +class test_uninstall(unittest.TestCase): """ Test the install/uninstall of a test module. The module is available in `openerp.tests` which should be present in the addons-path. @@ -82,4 +82,4 @@ class test_uninstall(unittest2.TestCase): if __name__ == '__main__': - unittest2.main() + unittest.main() diff --git a/openerp/addons/base/tests/test_view_validation.py b/openerp/addons/base/tests/test_view_validation.py index 4cd8b95bbaa8..68d35e38d1c9 100644 --- a/openerp/addons/base/tests/test_view_validation.py +++ b/openerp/addons/base/tests/test_view_validation.py @@ -2,7 +2,7 @@ # > PYTHONPATH=. python2 openerp/tests/test_view_validation.py from lxml import etree from StringIO import StringIO -import unittest2 +import unittest from openerp.tools.view_validation import (valid_page_in_book, valid_att_in_form, valid_type_in_colspan, valid_type_in_col, valid_att_in_field, valid_att_in_label, @@ -92,7 +92,7 @@ valid_tree = etree.parse(StringIO('''\ ''')).getroot() -class test_view_validation(unittest2.TestCase): +class test_view_validation(unittest.TestCase): """ Test the view validation code (but not the views themselves). """ def test_page_validation(self): @@ -128,4 +128,4 @@ class test_view_validation(unittest2.TestCase): if __name__ == '__main__': - unittest2.main() + unittest.main() diff --git a/openerp/addons/base/tests/test_views.py b/openerp/addons/base/tests/test_views.py index d73bc8d851ad..bc7b5edf11ce 100644 --- a/openerp/addons/base/tests/test_views.py +++ b/openerp/addons/base/tests/test_views.py @@ -2,7 +2,7 @@ from functools import partial import itertools -import unittest2 +import unittest from lxml import etree as ET from lxml.builder import E diff --git a/openerp/addons/test_convert/tests/test_convert.py b/openerp/addons/test_convert/tests/test_convert.py index b6981d8db9ff..7d1c575b2c78 100644 --- a/openerp/addons/test_convert/tests/test_convert.py +++ b/openerp/addons/test_convert/tests/test_convert.py @@ -1,5 +1,5 @@ import collections -import unittest2 +import unittest from lxml import etree as ET from lxml.builder import E @@ -72,10 +72,10 @@ class TestEvalXML(common.TransactionCase): with self.assertRaises(IOError): self.eval_xml(Field('test_nofile.txt', type='file'), obj) - @unittest2.skip("not tested") + @unittest.skip("not tested") def test_xml(self): pass - @unittest2.skip("not tested") + @unittest.skip("not tested") def test_html(self): pass diff --git a/openerp/addons/test_impex/tests/test_load.py b/openerp/addons/test_impex/tests/test_load.py index d9cbd5b100a0..2739fc3cc3e2 100644 --- a/openerp/addons/test_impex/tests/test_load.py +++ b/openerp/addons/test_impex/tests/test_load.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- import json import pkgutil -import unittest2 +import unittest import openerp.modules.registry import openerp diff --git a/openerp/modules/module.py b/openerp/modules/module.py index b03e31b3aa5a..bd46d05cde16 100644 --- a/openerp/modules/module.py +++ b/openerp/modules/module.py @@ -15,7 +15,7 @@ import unittest import threading from os.path import join as opj -import unittest2 +import unittest import openerp import openerp.tools as tools @@ -377,7 +377,7 @@ def adapt_version(version): def get_test_modules(module): """ Return a list of module for the addons potentially containing tests to - feed unittest2.TestLoader.loadTestsFromModule() """ + feed unittest.TestLoader.loadTestsFromModule() """ # Try to import the module modpath = 'openerp.addons.' + module try: @@ -446,14 +446,14 @@ def run_unit_tests(module_name, dbname, position=runs_at_install): threading.currentThread().testing = True r = True for m in mods: - tests = unwrap_suite(unittest2.TestLoader().loadTestsFromModule(m)) - suite = unittest2.TestSuite(itertools.ifilter(position, tests)) + tests = unwrap_suite(unittest.TestLoader().loadTestsFromModule(m)) + suite = unittest.TestSuite(itertools.ifilter(position, tests)) if suite.countTestCases(): t0 = time.time() t0_sql = openerp.sql_db.sql_counter _logger.info('%s running tests.', m.__name__) - result = unittest2.TextTestRunner(verbosity=2, stream=TestStream(m.__name__)).run(suite) + result = unittest.TextTestRunner(verbosity=2, stream=TestStream(m.__name__)).run(suite) if time.time() - t0 > 5: _logger.log(25, "%s tested in %.2fs, %s queries", m.__name__, time.time() - t0, openerp.sql_db.sql_counter - t0_sql) if not result.wasSuccessful(): @@ -471,8 +471,8 @@ def unwrap_suite(test): test suites). These can then be checked for run/skip attributes individually. - An alternative would be to use a variant of @unittest2.skipIf with a state - flag of some sort e.g. @unittest2.skipIf(common.runstate != 'at_install'), + An alternative would be to use a variant of @unittest.skipIf with a state + flag of some sort e.g. @unittest.skipIf(common.runstate != 'at_install'), but then things become weird with post_install as tests should *not* run by default there """ diff --git a/openerp/service/server.py b/openerp/service/server.py index b3ae669d169f..f21699ddcf1c 100644 --- a/openerp/service/server.py +++ b/openerp/service/server.py @@ -15,7 +15,7 @@ import subprocess import sys import threading import time -import unittest2 +import unittest import werkzeug.serving from werkzeug.debug import DebuggedApplication @@ -860,12 +860,12 @@ def load_test_file_py(registry, test_file): if mod_mod: mod_path, _ = os.path.splitext(getattr(mod_mod, '__file__', '')) if test_path == mod_path: - suite = unittest2.TestSuite() - for t in unittest2.TestLoader().loadTestsFromModule(mod_mod): + suite = unittest.TestSuite() + for t in unittest.TestLoader().loadTestsFromModule(mod_mod): suite.addTest(t) _logger.log(logging.INFO, 'running tests %s.', mod_mod.__name__) stream = openerp.modules.module.TestStream() - result = unittest2.TextTestRunner(verbosity=2, stream=stream).run(suite) + result = unittest.TextTestRunner(verbosity=2, stream=stream).run(suite) success = result.wasSuccessful() if hasattr(registry._assertion_report,'report_result'): registry._assertion_report.report_result(success) diff --git a/openerp/tests/common.py b/openerp/tests/common.py index 94f053659137..852bbb2a349e 100644 --- a/openerp/tests/common.py +++ b/openerp/tests/common.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- """ -The module :mod:`openerp.tests.common` provides unittest2 test cases and a few +The module :mod:`openerp.tests.common` provides unittest test cases and a few helpers and classes to write tests. """ @@ -15,7 +15,7 @@ import subprocess import threading import time import itertools -import unittest2 +import unittest import urllib2 import xmlrpclib from contextlib import contextmanager @@ -79,7 +79,7 @@ def post_install(flag): return obj return decorator -class BaseCase(unittest2.TestCase): +class BaseCase(unittest.TestCase): """ Subclass of TestCase for common OpenERP-specific code. @@ -352,7 +352,7 @@ class HttpCase(TransactionCase): try: phantom = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=None) except OSError: - raise unittest2.SkipTest("PhantomJS not found") + raise unittest.SkipTest("PhantomJS not found") try: self.phantom_poll(phantom, timeout) finally: diff --git a/openerp/tools/assertion_report.py b/openerp/tools/assertion_report.py index 3f2664b1bb43..729309915277 100644 --- a/openerp/tools/assertion_report.py +++ b/openerp/tools/assertion_report.py @@ -2,7 +2,7 @@ class assertion_report(object): """ Simple pair of success and failures counts (used to record YAML and XML - `assert` tags as well as unittest2 tests outcome (in this case, not + `assert` tags as well as unittest tests outcome (in this case, not individual `assert`)). """ def __init__(self): diff --git a/requirements.txt b/requirements.txt index 7b44c598c32e..215b9ac13fba 100644 --- a/requirements.txt +++ b/requirements.txt @@ -36,7 +36,6 @@ requests==2.6.0 simplejson==3.6.5 six==1.9.0 suds-jurko==0.6 -unittest2==0.8.0 vatnumber==1.2 vobject==0.6.6 wsgiref==0.1.2 diff --git a/setup.cfg b/setup.cfg index 35676683d74c..816d63a8304a 100644 --- a/setup.cfg +++ b/setup.cfg @@ -26,7 +26,6 @@ requires = python-reportlab python-requests python-simplejson - python-unittest2 python-vobject python-werkzeug python-yaml diff --git a/setup.py b/setup.py index d361fc61b707..824c8075c803 100644 --- a/setup.py +++ b/setup.py @@ -162,7 +162,6 @@ setup( 'requests', 'simplejson', 'suds-jurko', - 'unittest2', 'vatnumber', 'vobject', 'werkzeug', @@ -172,7 +171,6 @@ setup( 'SSL': ['pyopenssl'], }, tests_require=[ - 'unittest2', 'mock', ], **py2exe_options() diff --git a/setup/package.dfcentos b/setup/package.dfcentos index 76c2b2fbbce8..8917a7cce434 100644 --- a/setup/package.dfcentos +++ b/setup/package.dfcentos @@ -30,7 +30,6 @@ RUN yum install -d 0 -e 0 epel-release -y && \ python-reportlab \ python-requests \ python-simplejson \ - python-unittest2 \ python-vobject \ python-werkzeug \ python-yaml \ diff --git a/setup/package.dfdebian b/setup/package.dfdebian index 283c11f4c4e0..b84e7191aaa9 100644 --- a/setup/package.dfdebian +++ b/setup/package.dfdebian @@ -48,7 +48,6 @@ RUN apt-get update -qq && \ python-simplejson \ python-suds \ python-tz \ - python-unittest2 \ python-vatnumber \ python-vobject \ python-werkzeug \ -- GitLab