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

IndexError when running a check in a thread #127

Closed
fperrin opened this issue Jun 5, 2023 · 1 comment
Closed

IndexError when running a check in a thread #127

fperrin opened this issue Jun 5, 2023 · 1 comment
Labels

Comments

@fperrin
Copy link
Contributor

fperrin commented Jun 5, 2023

Hi,

When I run the following test:

import pytest_check as check
from concurrent.futures.thread import ThreadPoolExecutor

def force_fail():
    check.equal(1 + 1, 3, "Is 1+1 equal to 3?")

def test_thread():
    with ThreadPoolExecutor() as executor:
        task = executor.submit(force_fail)
        task.result()

pytest-check fails with the following:

venv/lib/python3.11/site-packages/pytest_check/pseudo_traceback.py:35: in _build_pseudo_trace_str
    (file, line, func, context) = get_full_context(level)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
level = 10
    def get_full_context(level):
>       (_, filename, line, funcname, contextlist) = inspect.stack()[level][0:5]
E       IndexError: list index out of range

The above is with python3.11 on macOS, but I've seen the same error on our Linux executors.

I am running:

$ pip freeze
iniconfig==2.0.0
packaging==23.1
pluggy==1.0.0
pytest==7.3.1
pytest-check==2.1.4
$ python --version
Python 3.11.3
@okken
Copy link
Owner

okken commented Jun 6, 2023

merged and released as version 2.1.5

@okken okken closed this as completed Jun 6, 2023
netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this issue Jun 10, 2023
2.1.5

Fixed
- Fix [127](okken/pytest-check#127) IndexError when running a check in a thread
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants