Skip to content
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

Capturing output causes test to fail. #2172

Closed
GandaG opened this issue Jan 4, 2017 · 3 comments
Closed

Capturing output causes test to fail. #2172

GandaG opened this issue Jan 4, 2017 · 3 comments

Comments

@GandaG
Copy link

GandaG commented Jan 4, 2017

When running with capture disabled, test passed but with enabled test fails with no reason given. Not sure if relevant, but the test is failing on a c extension module built with cython.

Windows 64-bit, Python 3.4.5 32-bit, pytest 3.0.5

A screenshot with pip list and the results of running py.test -s and py.test respectively. bethesdalib is the package being tested.

The test code:

import os
from bethlib.tesfive import pex, esp

def test_pex():
    ...

def test_esp():
    data_folder = os.path.join(os.path.abspath(os.path.dirname(__file__)), "data", "esp")
    for plugin_file in next(os.walk(data_folder), (None, None, []))[2]:
        plugin = esp.parse(os.path.join(data_folder, plugin_file))
        with open(os.path.join(data_folder, plugin_file), 'rb') as open_plugin:
            assert open_plugin.read() == esp.to_string(plugin)

Thanks!

@nicoddemus
Copy link
Member

Hi @GandaG,

pytest's exception capture in fd mode is probably causing the C extension module to fail somehow. It is probably the fault of the extension module not handling the fact that the out/err handles have been redirected, but is hard to know without debugging this somehow.

What happens if you run pytest with --capture=sys?

Could you try running pytest with a debugger attached and see where it crashes?

@GandaG
Copy link
Author

GandaG commented Jan 4, 2017

🤦‍♂️ Sorry, I just went full stupid. I am redirecting the output from the extension module to handle errors. It functions perfectly if I remove that part.

Thank you! And sorry :/

@GandaG GandaG closed this as completed Jan 4, 2017
@nicoddemus
Copy link
Member

Thank you! And sorry :/

No worries! Thanks for closing the issue then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants