-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Capsys doesn't correctly handle whitespace characters #3524
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
GitMate.io thinks possibly related issues are #1553 (Assert diff does not handle newline), #1996 (Warnings handling), #3207 (capsys does not follow the OS newline rules for print), #439 (capsys fixture does not collect the same test output as reported by pytest), and #353 (py.test doesn't expose that an exception occurred while handling another). |
The output looks to be what I expect at least -- do you mean to have your "array" be a string or are you forgetting a >>> def reverse_array(array):
... return ' '.join(array[::-1])
...
>>> reverse_array('1 2 3')
'3 2 1'
>>> reverse_array('123')
'3 2 1'
>>> # how I think you mean to implement this
... def reverse_array(array):
... return ' '.join(array.split()[::-1])
...
>>> reverse_array('1 2 3')
'3 2 1'
>>> reverse_array('123')
'123'
>>> reverse_array('hello world')
'world hello' Note that I've changed |
You're right! I'm closing the issue. Thanks for your help @asottile |
you may also find |
I wrote this very simple function:
and relative unit-test:
I would expect the tests to pass but for some reason
capsys
is not correctly handling the whitespaces in the result. Here is the stdout:These are the package installed in my virtualenv:
The text was updated successfully, but these errors were encountered: