Closed justinmayer closed 4 years ago
Test run output before these changes were applied:
➤ pytest
============================== test session starts ==============================
platform darwin -- Python 3.7.6, pytest-5.3.5, py-1.8.1, pluggy-0.13.1
rootdir: /Projects/virtualfish, inifile: tox.ini
plugins: xdist-1.31.0, forked-1.1.3
gw0 [10] / gw1 [10]
.......F.. [100%]
=================================== FAILURES ====================================
_______________________________ test_return_value _______________________________
[gw1] darwin -- Python 3.7.6 /Virtualenvs/tempenv-1dea256362231/bin/python3.7
f = <virtualfish.test.repl.Fish object at 0x10bd90ed0>
> ???
/Projects/virtualfish/virtualfish/test/test_repl.py:20:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
virtualfish/test/repl.py:107: in run
sys.stderr.write(error)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <_pytest.capture.EncodedFile object at 0x10ba23910>, obj = b''
def write(self, obj):
if isinstance(obj, str):
obj = obj.encode(self.encoding, "replace")
else:
raise TypeError(
> "write() argument must be str, not {}".format(type(obj).__name__)
)
E TypeError: write() argument must be str, not bytes
../../Virtualenvs/tempenv-1dea256362231/lib/python3.7/site-packages/_pytest/capture.py:425: TypeError
----------------------------- Captured stdout call ------------------------------
b''
========================== 1 failed, 9 passed in 3.13s ==========================
I just connected this repo to GitHub Actions CI, where this test failure can be seen: https://github.com/justinmayer/virtualfish/runs/507356331?check_suite_focus=true
I noticed that running the tests currently results in a test failure due to a TypeError in the REPL test code's
run()
function:I don't know whether it is an appropriate fix, but I resolved the error by converting the output bytes to strings.