Commit 57e89244 authored by Marius Gedminas's avatar Marius Gedminas

Fix fstest tests on Python 3

parent 37c20b52
......@@ -36,7 +36,7 @@ from __future__ import print_function
# ZODB.FileStorage. If anything about the FileStorage layout changes,
# this file will need to be udpated.
import string
import binascii
import struct
import sys
......@@ -55,16 +55,13 @@ DREC_HDR_LEN = 42
VERBOSE = 0
def hexify(s):
"""Format an 8-bit string as hex"""
l = []
for c in s:
h = hex(ord(c))
if h[:2] == '0x':
h = h[2:]
if len(h) == 1:
l.append("0")
l.append(h)
return "0x" + ''.join(l)
r"""Format an 8-bit string as hex
>>> hexify(b'\x00\xff\xaa\xcc')
'0x00ffaacc'
"""
return '0x' + binascii.hexlify(s).decode()
def chatter(msg, level=1):
if VERBOSE >= level:
......
......@@ -11,9 +11,13 @@
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
from zope.testing import setupstack
import doctest
import re
import unittest
import ZODB
from zope.testing import setupstack
from zope.testing.renormalizing import RENormalizing
def test_fstest_verbose():
r"""
......@@ -39,6 +43,13 @@ def test_fstest_verbose():
def test_suite():
return doctest.DocTestSuite(
setUp=setupstack.setUpDirectory, tearDown=setupstack.tearDown)
checker = RENormalizing([
# Python 3 drops the u'' prefix on unicode strings
(re.compile(r"u('[^']*')"), r"\1"),
])
return unittest.TestSuite([
doctest.DocTestSuite('ZODB.scripts.fstest', checker=checker),
doctest.DocTestSuite(setUp=setupstack.setUpDirectory,
tearDown=setupstack.tearDown),
])
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