Last active
April 16, 2019 15:33
-
-
Save antocuni/b444c2c8b37821a95f45bee42e78d3cf to your computer and use it in GitHub Desktop.
pytest capture bug
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# if you uncomment this, the test works as expected | |
import dummy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <Python.h> | |
#include <iostream> | |
static PyMethodDef dummy_methods[] = { | |
{NULL, NULL, 0, NULL} | |
}; | |
PyMODINIT_FUNC initdummy(void) { | |
PyObject* dummy_module = Py_InitModule3("dummy", dummy_methods, | |
"dummy module"); | |
// if you comment out this, test_noflush works as expected | |
std::cout << "Initialising dummy..." << std::endl; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from setuptools import setup, Extension | |
setup( | |
name="dummy", | |
ext_modules = [Extension('dummy', ['dummy.cpp'])], | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import time | |
def test_noflush(capfd): | |
with capfd.disabled(): | |
for i in range(10): | |
sys.stdout.write('%d\n' % i) | |
# if you uncomment this, you can see the output again | |
#sys.stdout.flush() | |
time.sleep(0.2) | |
def test_enter_pdb(): | |
0/0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment