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