|
12 | 12 | # |
13 | 13 | ############################################################################## |
14 | 14 | """Resolution ordering utility tests""" |
| 15 | +import doctest |
| 16 | +import re |
15 | 17 | import unittest |
16 | 18 |
|
| 19 | +import zope.testing.renormalizing |
| 20 | + |
17 | 21 |
|
18 | 22 | # pylint:disable=blacklisted-name |
19 | 23 | # pylint:disable=protected-access |
@@ -298,23 +302,38 @@ def _check_handler_complex_diamond(self): |
298 | 302 |
|
299 | 303 | expected = """\ |
300 | 304 | Object <InterfaceClass {name}> has different legacy and C3 MROs: |
301 | | - Legacy RO (len=7) C3 RO (len=7; inconsistent=no) |
302 | | - ======================================================== |
| 305 | + Legacy RO (len=7) C3 RO (len=7; inconsistent=no) |
| 306 | + ============================================================= |
303 | 307 | interface.tests.test_ro.A interface.tests.test_ro.A |
304 | 308 | interface.tests.test_ro.B interface.tests.test_ro.B |
305 | 309 | - interface.tests.test_ro.E |
306 | 310 | interface.tests.test_ro.C interface.tests.test_ro.C |
307 | 311 | interface.tests.test_ro.D interface.tests.test_ro.D |
308 | 312 | + interface.tests.test_ro.E |
309 | 313 | interface.tests.test_ro.F interface.tests.test_ro.F |
310 | | - zope.interface.Interface zope.interface.Interface""".format( |
| 314 | + interface.Interface interface.Interface""".format( |
311 | 315 | name="interface.tests.test_ro.A" |
312 | 316 | ) |
313 | 317 |
|
314 | | - self.assertEqual( |
315 | | - '\n'.join(ln.rstrip() for ln in record.getMessage().splitlines()), |
316 | | - expected, |
| 318 | + checker = zope.testing.renormalizing.OutputChecker([ |
| 319 | + (re.compile(r'zope\.'), ''), # zope is not always there |
| 320 | + # space in headline is not consistent |
| 321 | + (re.compile( |
| 322 | + r'Legacy RO \(len=7\) +C3 RO \(len=7; inconsistent=no\)'), |
| 323 | + 'Legacy RO (len=7) C3 RO (len=7; inconsistent=no)'), |
| 324 | + (re.compile(r'=+'), ''), # header underline length varies |
| 325 | + (re.compile(r' +\+'), ' +'), # table column spacing varies |
| 326 | + (re.compile(r'interface\.Interface +interface\.Interface'), |
| 327 | + 'interface.Interface interface.Interface'), |
| 328 | + # spacing varies in last line |
| 329 | + ] |
317 | 330 | ) |
| 331 | + got = '\n'.join(ln.rstrip() for ln in record.getMessage().splitlines()) |
| 332 | + self.assertTrue( |
| 333 | + checker.check_output( |
| 334 | + expected, got, 0), checker.output_difference( |
| 335 | + doctest.Example( |
| 336 | + got, expected), got, 0)) |
318 | 337 |
|
319 | 338 | def test_ExtendedPathIndex_implement_thing_implementedby_super(self): |
320 | 339 | # See |
|
0 commit comments