From 5c39c28ce88389ef35c74eca48e0042d2394dd76 Mon Sep 17 00:00:00 2001 From: Vincent Fretin Date: Mon, 15 May 2017 11:28:50 +0200 Subject: [PATCH] fix doctest on Python 3.6 --- src/keas/kmi/persistent.txt | 2 +- src/keas/kmi/tests.py | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/keas/kmi/persistent.txt b/src/keas/kmi/persistent.txt index cabb877..ac516cd 100644 --- a/src/keas/kmi/persistent.txt +++ b/src/keas/kmi/persistent.txt @@ -152,7 +152,7 @@ error: >>> pwd.password Traceback (most recent call last): ... - ValueError: need more than 1 value to unpack + ValueError: not enough values to unpack (expected 2, got 1) But we can apply the conversion step: diff --git a/src/keas/kmi/tests.py b/src/keas/kmi/tests.py index 4742af7..f022811 100644 --- a/src/keas/kmi/tests.py +++ b/src/keas/kmi/tests.py @@ -14,12 +14,14 @@ """Test Setup """ import doctest +import re import tempfile import transaction import unittest from zope.app.testing import setup from zope.component import provideUtility +from zope.testing.renormalizing import RENormalizing from keas.kmi.testing import TestingKeyManagementFacility from keas.kmi.interfaces import IKeyManagementFacility @@ -39,6 +41,11 @@ def tearDownPersistent(test): def test_suite(): + checker = RENormalizing([ + # fix doctest for ValueError exception on Python < 3.6 + (re.compile(r"ValueError: need more than 1 value to unpack"), + "ValueError: not enough values to unpack (expected 2, got 1)") + ]) return unittest.TestSuite([ doctest.DocFileSuite( 'README.txt', @@ -49,5 +56,6 @@ def test_suite(): doctest.DocFileSuite( 'persistent.txt', setUp=setUpPersistent, tearDown=tearDownPersistent, - optionflags=doctest.NORMALIZE_WHITESPACE|doctest.ELLIPSIS), + optionflags=doctest.NORMALIZE_WHITESPACE|doctest.ELLIPSIS, + checker=checker), ])