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

testDynamicClassGeneration: use assertRegex

This was old compatibility code
parent fcd26be0
...@@ -35,6 +35,7 @@ import shutil ...@@ -35,6 +35,7 @@ import shutil
import tempfile import tempfile
import unittest import unittest
import warnings import warnings
import re
import sys import sys
import transaction import transaction
...@@ -3215,12 +3216,9 @@ class Test(ERP5TypeTestCase): ...@@ -3215,12 +3216,9 @@ class Test(ERP5TypeTestCase):
ERP5TypeTestCase.__bases__ = base_tuple ERP5TypeTestCase.__bases__ = base_tuple
ERP5TypeTestLoader.loadTestsFromNames = ERP5TypeTestLoader_loadTestsFromNames ERP5TypeTestLoader.loadTestsFromNames = ERP5TypeTestLoader_loadTestsFromNames
# assertRegexpMatches is only available from Python >= 2.7
import re
output = self._component_tool.readTestOutput() output = self._component_tool.readTestOutput()
self.assertNotEqual(re.search('Ran 1 test.*OK', output, re.DOTALL), None, expected_msg_re = re.compile('Ran 1 test.*OK', re.DOTALL)
"Expected 'Ran 1 test.*OK' in '%s'" % output) self.assertRegex(output, expected_msg_re)
# Secondly, add a test which will always fail # Secondly, add a test which will always fail
source_code += ''' source_code += '''
...@@ -3244,12 +3242,9 @@ class Test(ERP5TypeTestCase): ...@@ -3244,12 +3242,9 @@ class Test(ERP5TypeTestCase):
ERP5TypeTestCase.__bases__ = base_tuple ERP5TypeTestCase.__bases__ = base_tuple
ERP5TypeTestLoader.loadTestsFromNames = ERP5TypeTestLoader_loadTestsFromNames ERP5TypeTestLoader.loadTestsFromNames = ERP5TypeTestLoader_loadTestsFromNames
# assertRegexpMatches is only available from Python >= 2.7
import re
output = self._component_tool.readTestOutput() output = self._component_tool.readTestOutput()
expected_msg_re_str = 'Ran 2 tests.*FAILED \(failures=1\)' expected_msg_re = re.compile('Ran 2 tests.*FAILED \(failures=1\)', re.DOTALL)
self.assertNotEqual(re.search(expected_msg_re_str, output, re.DOTALL), None, self.assertRegex(output, expected_msg_re)
"Expected '%s' in '%s'" % (expected_msg_re_str, output))
def testERP5Broken(self): def testERP5Broken(self):
# Create a broken ghost object # Create a broken ghost object
......
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