Skip to content

pytest INTERNALERROR when loading a fixture fails when running tests in an executable #849

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

Closed
campos-ddc opened this issue Jul 16, 2015 · 1 comment
Assignees
Labels
type: bug problem that needs to be addressed

Comments

@campos-ddc
Copy link

If running tests within an executable (cx_freeze), sometimes this function fails and raises an INTERNALERROR:

class FixtureLookupError(LookupError):

    def formatrepr(self):

        # ... omitted some stuff

        for function in stack:
            fspath, lineno = getfslineno(function)
            lines, _ = inspect.getsourcelines(function)

The error happens because source files are not available at this moment.

We override inspect.getsourcelines to raise an exception when inside an executable, which makes the traceback look like this:

INTERNALERROR> Traceback (most recent call last):
INTERNALERROR>   File "<PY>\_pytest\main.py", line 84, in
wrap_session
INTERNALERROR>   File "<PY>\_pytest\main.py", line 122, in _main
INTERNALERROR>   File "<PY>\_pytest\core.py", line 521, in
__call__
INTERNALERROR>   File "<PY>\_pytest\core.py", line 528, in
_docall
INTERNALERROR>   File "<PY>\_pytest\core.py", line 394, in
execute
INTERNALERROR>   File "<remote exec>", line 59, in pytest_runtestloop
INTERNALERROR>   File "<remote exec>", line 72, in run_tests
INTERNALERROR>   File "<PY>\_pytest\core.py", line 521, in
__call__
INTERNALERROR>   File "<PY>\_pytest\core.py", line 528, in
_docall
INTERNALERROR>   File "<PY>\_pytest\core.py", line 393, in
execute
INTERNALERROR>   File "<PY>\_pytest\core.py", line 113, in
wrapped_call
INTERNALERROR>   File "<PY>\_pytest\core.py", line 138, in
get_result
INTERNALERROR>   File "<PY>\_pytest\core.py", line 123, in
__init__
INTERNALERROR>   File "<PY>\_pytest\core.py", line 394, in
execute
INTERNALERROR>   File "<PY>\pytest_timeout.py", line 72, in
pytest_runtest_protocol
INTERNALERROR>   File "<PY>\_pytest\core.py", line 394, in
execute
INTERNALERROR>   File "<PY>\_pytest\runner.py", line 65, in
pytest_runtest_protocol
INTERNALERROR>   File "<PY>\_pytest\runner.py", line 72, in
runtestprotocol
INTERNALERROR>   File "<PY>\_pytest\runner.py", line 121, in
call_and_report
INTERNALERROR>   File "<PY>\_pytest\core.py", line 521, in
__call__
INTERNALERROR>   File "<PY>\_pytest\core.py", line 528, in
_docall
INTERNALERROR>   File "<PY>\_pytest\core.py", line 393, in
execute
INTERNALERROR>   File "<PY>\_pytest\core.py", line 109, in
wrapped_call
INTERNALERROR>   File "<PY>\_pytest\skipping.py", line 157, in
pytest_runtest_makereport
INTERNALERROR>   File "<PY>\_pytest\core.py", line 138, in
get_result
INTERNALERROR>   File "<PY>\_pytest\core.py", line 123, in
__init__
INTERNALERROR>   File "<PY>\_pytest\core.py", line 394, in
execute
INTERNALERROR>   File "<PY>\_pytest\runner.py", line 227, in
pytest_runtest_makereport
INTERNALERROR>   File "<PY>\_pytest\python.py", line 618, in
_repr_failure_py
INTERNALERROR>   File "<PY>\_pytest\main.py", line 392, in
_repr_failure_py
INTERNALERROR>   File "<PY>\_pytest\python.py", line 1540, in
formatrepr
INTERNALERROR>   File "<PY>\lib\inspect.py", line 690, in getsourcelines
INTERNALERROR>   File "<PY>\cx_Freeze\initscripts\ConsoleRedirect.py", line 50, in findsource
INTERNALERROR> IOError: Unable to find source
INTERNALERROR> Traceback (most recent call last):
INTERNALERROR>   File "<PY>\_pytest\main.py", line 84, in
wrap_session
INTERNALERROR>   File "<PY>\_pytest\main.py", line 122, in _main
INTERNALERROR>   File "<PY>\_pytest\core.py", line 521, in
__call__
INTERNALERROR>   File "<PY>\_pytest\core.py", line 528, in
_docall
INTERNALERROR>   File "<PY>\_pytest\core.py", line 394, in
execute
INTERNALERROR>   File "<PY>\xdist\dsession.py", line 504, in
pytest_runtestloop
INTERNALERROR>   File "<PY>\xdist\dsession.py", line 522, in
loop_once
INTERNALERROR>   File "<PY>\xdist\dsession.py", line 560, in
slave_slavefinished
INTERNALERROR> AssertionError:
('my_test.py::testSomething', <SlaveController gw1>)
@nicoddemus nicoddemus self-assigned this Jul 16, 2015
@nicoddemus nicoddemus added the type: bug problem that needs to be addressed label Jul 16, 2015
@nicoddemus
Copy link
Member

This has been fixed in 2.7.1 already, sorry for not remembering this! 😅

Duplicate of #553.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug problem that needs to be addressed
Projects
None yet
Development

No branches or pull requests

2 participants