Skip to content

Instantly share code, notes, and snippets.

@dusktreader
Created December 21, 2018 19:09
Show Gist options
  • Save dusktreader/ee17bcc1cf282093556cabc636e4ef00 to your computer and use it in GitHub Desktop.
Save dusktreader/ee17bcc1cf282093556cabc636e4ef00 to your computer and use it in GitHub Desktop.
capsys.disabled() not working as expected
___________________________ TestXXX.test_xxx ___________________________
...
def test_csv(self, app, client, basic_user, bulk_add_test_data, capsys):
print(app.show_routes(rule_pattern=r'/api2/xxx/.*'))
response = client.get(
flask.url_for(
'xxx',
),
headers=guard.pack_header_for_user(basic_user),
)
with capsys.disabled():
import ipdb
> ipdb.set_trace()
test/api/xxx.py:89:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
../../.pyenv/versions/3.6.5/lib/python3.6/contextlib.py:85: in __exit__
def __exit__(self, type, value, traceback):
../../.pyenv/versions/3.6.5/lib/python3.6/bdb.py:53: in trace_dispatch
return self.dispatch_call(frame, arg)
../../.pyenv/versions/3.6.5/lib/python3.6/bdb.py:85: in dispatch_call
self.user_call(frame, arg)
../../.pyenv/versions/3.6.5/lib/python3.6/pdb.py:251: in user_call
self.interaction(frame, None)
../../.local/share/virtualenvs/cem-data-bYY-kAuC/lib/python3.6/site-packages/IPython/core/debugger.py:297: in interaction
OldPdb.interaction(self, frame, traceback)
../../.pyenv/versions/3.6.5/lib/python3.6/pdb.py:352: in interaction
self._cmdloop()
../../.pyenv/versions/3.6.5/lib/python3.6/pdb.py:321: in _cmdloop
self.cmdloop()
../../.pyenv/versions/3.6.5/lib/python3.6/cmd.py:126: in cmdloop
line = input(self.prompt)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
self = <_pytest.capture.DontReadFromInput object at 0x7ff4a2e9a518>, args = ()
def read(self, *args):
> raise IOError("reading from stdin while output is captured")
E OSError: reading from stdin while output is captured
../../.local/share/virtualenvs/cem-data-bYY-kAuC/lib/python3.6/site-packages/_pytest/capture.py:653: OSError
----------------------------- Captured stdout call -----------------------------
[
[ 'rule', 'methods', 'endpoint', ],
[ '/api2/xxx/csv', 'GET,HEAD,OPTIONS', 'xxx.csv', ],
[ '/api2/xxx/merge', 'POST,OPTIONS', 'xxx.merge', ],
]
---------------------------- Captured logging call -----------------------------
[ INFO ] REQUEST -> /api2/xxx/csv [GET] ()
================ 1 failed, 1 warnings, 1 error in 3.60 seconds =================
Exception ignored in: <generator object disabled at 0x7ff48f6d19e8>
Traceback (most recent call last):
File "/home/xxx/.local/share/virtualenvs/xxx-bYY-kAuC/lib/python3.6/site-packages/_pytest/capture.py", line 380, in disabled
File "/home/xxx/.pyenv/versions/3.6.5/lib/python3.6/contextlib.py", line 99, in __exit__
File "/home/xxx/.local/share/virtualenvs/cem-data-bYY-kAuC/lib/python3.6/site-packages/_pytest/capture.py", line 167, in global_and_fixture_disabled
File "/home/xxx/.local/share/virtualenvs/cem-data-bYY-kAuC/lib/python3.6/site-packages/_pytest/capture.py", line 120, in resume_global_capture
AttributeError: 'NoneType' object has no attribute 'resume_capturing'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment