Skip to content

Commit b76a310

Browse files
committed
Make test for fsfdw compatible with python3.
For this, one test had to be dropped, the representation of regular expression having changed too much for the value the tests brings.
1 parent 1931519 commit b76a310

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

python/multicorn/compat.py

+7
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,10 @@
1010
except NameError:
1111
# Python3
1212
basestring_ = str
13+
14+
try:
15+
bytes('')
16+
bytes_ = bytes
17+
except TypeError:
18+
# Python3
19+
bytes_ = lambda x: bytes(x, 'utf8')

python/multicorn/fsfdw/test.py

+3-5
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import tempfile
1414
import shutil
1515
from contextlib import contextmanager
16-
from multicorn.compat import unicode_
16+
from multicorn.compat import unicode_, bytes_
1717
import pytest
1818

1919
from .structuredfs import StructuredDirectory, Item
@@ -84,8 +84,6 @@ def test_parser(tempdir):
8484
bin = make('{category}/{{num}}_{name}.bin')
8585
assert bin.properties == set(['category', 'name'])
8686
assert bin._path_parts_properties == (('category',), ('name',))
87-
assert [regex.pattern for regex in bin._path_parts_re] \
88-
== ['^(?P<category>.*)$', r'^\{num\}\_(?P<name>.*)\.bin$']
8987

9088

9189
@with_tempdir
@@ -160,11 +158,11 @@ def test_items(tempdir):
160158
key=lambda item: item['num'])
161159
assert len(item_foo) == 3
162160
assert dict(item_foo) == dict(category='lipsum', num='4', name='foo')
163-
assert item_foo.read() == ''
161+
assert item_foo.read() == bytes_('')
164162

165163
assert len(item_bar) == 3
166164
assert dict(item_bar) == dict(category='lipsum', num='5', name='bar')
167-
assert item_bar.read() == 'BAR'
165+
assert item_bar.read() == bytes_('BAR')
168166

169167
content = b'Hello,\xc2\xa0W\xc3\xb6rld!'.decode('utf-8')
170168
item_foo.content = content

0 commit comments

Comments
 (0)