tests: simplify and deprecate assertSameSet
Since a long time python unittest provides good assertions and we don't need to build out own.
Showing
-
Owner
We have test failure on master but assertion message is unreadable ( https://nexedijs.erp5.net/#/test_result_module/20200709-55EFE4ED/75 ) this is to try to get a better message
-
Owner
test for this is running on https://nexedijs.erp5.net/#/test_result_module/20200709-771FF055?page=form&view=view
-
Owner
This improves error reporting a lot, before:
====================================================================== FAIL: testConfiguredBusinessTemplateList (erp5.component.test.erp5_version.testOfficeJSSDKConfigurator.TestOfficeJSSDKConfigurator) Make sure Installed business Templates are ---------------------------------------------------------------------- Traceback (most recent call last): File "<portal_components/test.erp5.testOfficeJSSDKConfigurator>", line 247, in testConfiguredBusinessTemplateList File "/srv/slapgrid/slappart8/srv/testnode/aai/soft/2da363b8a5af316bd4fab5fb9b352d79/parts/erp5/product/ERP5Type/tests/ERP5TypeTestCase.py", line 668, in assertSameSet self.assertEqual(set(a), set(b), msg) AssertionError: ['erp5_accounting', 'erp5_administration', 'erp5_base', 'erp5_code_mirror', 'erp5_configurator', 'erp5_configurator_standard', 'erp5_core', 'erp5_core_proxy_field_legacy', 'erp5_crm', 'erp5_dms', 'erp5_font', 'erp5_forge', 'erp5_full_text_mroonga_catalog', 'erp5_gadget_interface_validator', 'erp5_hal_json_style', 'erp5_ingestion', 'erp5_ingestion_mysql_innodb_catalog', 'erp5_jquery', 'erp5_jquery_plugin_colorpicker', 'erp5_jquery_plugin_elastic', 'erp5_jquery_plugin_jqchart', 'erp5_jquery_plugin_mbmenu', 'erp5_jquery_plugin_sheet', 'erp5_jquery_sheet_editor', 'erp5_jquery_sheet_js_editor', 'erp5_jquery_ui', 'erp5_knowledge_pad', 'erp5_l10n_fa', 'erp5_minipaint', 'erp5_monaco_editor', 'erp5_multimedia', 'erp5_mysql_innodb_catalog', 'erp5_notebook', 'erp5_officejs', 'erp5_officejs_connector', 'erp5_officejs_jquery_app', 'erp5_officejs_ooffice', 'erp5_officejs_ui_test', 'erp5_only_office', 'erp5_pdm', 'erp5_project', 'erp5_property_sheets', 'erp5_simulation', 'erp5_smart_assistant', 'erp5_svg_editor', 'erp5_test_result', 'erp5_trade', 'erp5_ui_test', 'erp5_ui_test_core', 'erp5_upgrader', 'erp5_upgrader_officejs_sdk', 'erp5_web', 'erp5_web_renderjs_ui', 'erp5_web_renderjs_ui_test', 'erp5_web_service', 'erp5_workflow', 'erp5_xhtml_style', 'officejs_todomvc'] != ['erp5_accounting', 'erp5_administration', 'erp5_base', 'erp5_code_mirror', 'erp5_configurator', 'erp5_configurator_standard', 'erp5_core', 'erp5_core_proxy_field_legacy', 'erp5_crm', 'erp5_dms', 'erp5_font', 'erp5_forge', 'erp5_full_text_mroonga_catalog', 'erp5_gadget_interface_validator', 'erp5_hal_json_style', 'erp5_ingestion', 'erp5_ingestion_mysql_innodb_catalog', 'erp5_jquery', 'erp5_jquery_plugin_colorpicker', 'erp5_jquery_plugin_elastic', 'erp5_jquery_plugin_jqchart', 'erp5_jquery_plugin_mbmenu', 'erp5_jquery_plugin_sheet', 'erp5_jquery_sheet_editor', 'erp5_jquery_sheet_js_editor', 'erp5_jquery_ui', 'erp5_knowledge_pad', 'erp5_l10n_fa', 'erp5_minipaint', 'erp5_monaco_editor', 'erp5_multimedia', 'erp5_mysql_innodb_catalog', 'erp5_notebook', 'erp5_officejs', 'erp5_officejs_connector', 'erp5_officejs_jquery_app', 'erp5_officejs_ooffice', 'erp5_officejs_ui_test', 'erp5_only_office', 'erp5_pdm', 'erp5_project', 'erp5_property_sheets', 'erp5_simulation', 'erp5_smart_assistant', 'erp5_svg_editor', 'erp5_test_result', 'erp5_trade', 'erp5_ui_test', 'erp5_ui_test_core', 'erp5_upgrader', 'erp5_upgrader_officejs_sdk', 'erp5_web', 'erp5_web_renderjs_ui', 'erp5_web_renderjs_ui_test', 'erp5_web_renderjs_ui_test_core', 'erp5_web_service', 'erp5_workflow', 'erp5_xhtml_style', 'officejs_todomvc']
after :
====================================================================== FAIL: testConfiguredBusinessTemplateList (erp5.component.test.erp5_version.testOfficeJSSDKConfigurator.TestOfficeJSSDKConfigurator) Make sure Installed business Templates are ---------------------------------------------------------------------- Traceback (most recent call last): File "<portal_components/test.erp5.testOfficeJSSDKConfigurator>", line 247, in testConfiguredBusinessTemplateList File "/srv/slapgrid/slappart6/srv/testnode/alf/soft/4ce2fca7da4479439b2cfa9be3f5a376/parts/erp5/product/ERP5Type/tests/ERP5TypeTestCase.py", line 663, in assertSameSet self.assertEqual(set(a), set(b), msg) AssertionError: Items in the second set but not the first: 'erp5_web_renderjs_ui_test_core'
I thought about replacing all occurrences of this method by simple assertEqual, but they are too many. This could be done with a 2to3 fixer but I was lazy, also in many places what we would want is not
self.assertEqual(set(a), set(b))
but probably
self.assertEqual(sorted(a), sorted(b))
when duplicates are not expected
Please register or sign in to comment