[Scons-users] Question over test.must_contain

RW garlicbready at googlemail.com
Tue Jul 4 09:06:53 EDT 2017


Hi,
I've noticed another python3 bug / fix

python3 runtest.py test/Docbook/basic/xinclude/xinclude.py

1/1 (100.00%) /usr/bin/python3 -tt test/Docbook/basic/xinclude/xinclude.py
Traceback (most recent call last):
  File "test/Docbook/basic/xinclude/xinclude.py", line 47, in <module>
    test.must_contain(test.workpath('manual_xi.xml'),'<para>This is an
included text.')
  File "/home/ric/scons-temp/scons_patched/QMTest/TestCommon.py", line 278,
in must_contain
    contains = find(file_contents, required)
  File "/home/ric/scons-temp/scons_patched/QMTest/TestCommon.py", line 275,
in find
    return o.index(l)
TypeError: a bytes-like object is required, not 'str'

There's a couple of different ways to fix this

# Option1
the simplest is to just change

```
test.must_contain(test.workpath('manual_xi.xml'),'<para>This is an included
text.')
to
test.must_contain(test.workpath('manual_xi.xml'),'<para>This is an included
text.', mode='r')
```

which what the other tests seem to do

# Option2
To maintain consistency between python versions, another possible option
(maybe at the same time) is to alter the
must_contain function within QMTest/TestCommon.py
However with this approach your assuming must_contains always deals with
binary and not text data which may be incorrect

```
import codecs
file_contents = codecs.latin_1_decode(file_contents)[0]
```

Would both options or just option 1 be the best way?

Many Thanks
Richard
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://pairlist4.pair.net/pipermail/scons-users/attachments/20170704/fa37a95c/attachment.html>


More information about the Scons-users mailing list