Commit d80b2ec5 authored by Jérome Perrin's avatar Jérome Perrin

payroll_l10n_fr: simplify testDSNSocialDeclarationReport and fix py3 compatibility

unittest does a good job of explaining the differences when using
splitlines on long texts, no need to compute a diff ourselves.
parent e8fbe698
...@@ -24,13 +24,13 @@ ...@@ -24,13 +24,13 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
# #
############################################################################## ##############################################################################
import difflib
import os import os
import time import time
import six
from DateTime import DateTime from DateTime import DateTime
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
class TestDSNSocialDeclarationReport(ERP5TypeTestCase): class TestDSNSocialDeclarationReport(ERP5TypeTestCase):
""" """
Test Suite for the generation of the French Social Declaration Report, Test Suite for the generation of the French Social Declaration Report,
...@@ -60,8 +60,13 @@ class TestDSNSocialDeclarationReport(ERP5TypeTestCase): ...@@ -60,8 +60,13 @@ class TestDSNSocialDeclarationReport(ERP5TypeTestCase):
""" """
test_dsn = self.dsn_module['test_model'] test_dsn = self.dsn_module['test_model']
test_dsn.DSNMonthlyReport_makeReport() test_dsn.DSNMonthlyReport_makeReport()
reference_DSN = getattr(self.portal.portal_skins.erp5_payroll_l10n_fr_test, "test_model.dsn").data reference_DSN = bytes(
diff_list = [] getattr(self.portal.portal_skins.erp5_payroll_l10n_fr_test, "test_model.dsn").data
for unit_diff in difflib.unified_diff(reference_DSN.split('\n'), test_dsn.getTextContent().split('\n')): )
diff_list.append(unit_diff) if six.PY3:
self.assertEqual(reference_DSN, test_dsn.getTextContent(), msg='\n'.join(diff_list)) reference_DSN = reference_DSN.decode('utf-8')
self.maxDiff = None
self.assertEqual(
test_dsn.getTextContent().splitlines(),
reference_DSN.splitlines(),
)
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment