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

when I try to compare numbers I get "IndexError: list index out of range" #85

Closed
ghost opened this issue Aug 19, 2022 · 10 comments
Closed
Assignees
Labels

Comments

@ghost
Copy link

ghost commented Aug 19, 2022

when I try to compare:
pytest_check.greater(1, 2)

I get:
Traceback (most recent call last):
File "D:\Project\autotest_vm\venv\lib\site-packages\pytest_check\check_methods.py", line 84, in wrapper
func(*args, **kwds)
File "D:\Project\autotest_vm\venv\lib\site-packages\pytest_check\check_methods.py", line 175, in greater
assert a > b, msg
AssertionError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "D:\Project\autotest_vm\3.py", line 2, in
pytest_check.greater(1, 2)
File "D:\Project\autotest_vm\venv\lib\site-packages\pytest_check\check_methods.py", line 89, in wrapper
log_failure(e)
File "D:\Project\autotest_vm\venv\lib\site-packages\pytest_check\check_methods.py", line 304, in log_failure
(file, line, func, context) = get_full_context(level)
File "D:\Project\autotest_vm\venv\lib\site-packages\pytest_check\check_methods.py", line 292, in get_full_context
(_, filename, line, funcname, contextlist) = inspect.stack()[level][0:5]
IndexError: list index out of range

Why i getting "During handling of the above exception, another exception occurred"

@okken okken self-assigned this Aug 19, 2022
@okken okken added the bug label Aug 19, 2022
@okken
Copy link
Owner

okken commented Aug 19, 2022

I think this is an issue with windows paths and multiple drive letters.

@okken
Copy link
Owner

okken commented Aug 21, 2022

Nope. Not a path thing. I’m working on a fix.

@okken
Copy link
Owner

okken commented Aug 21, 2022

This should be fixed by version 1.0.7. Please check.

@okken okken closed this as completed Aug 21, 2022
@zerocen
Copy link

zerocen commented Aug 22, 2022

I use the version 1.0.7. But still getting the error

>>> import pytest_check as check
>>> check.greater(1, 2)
Traceback (most recent call last):
  File "C:\Users\ZL\AppData\Local\Programs\Python\Python310\lib\site-packages\pytest_check\check_methods.py", line 84, in wrapper
    func(*args, **kwds)
  File "C:\Users\ZL\AppData\Local\Programs\Python\Python310\lib\site-packages\pytest_check\check_methods.py", line 175, in greater
    assert a > b, msg
AssertionError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\ZL\AppData\Local\Programs\Python\Python310\lib\site-packages\pytest_check\check_methods.py", line 89, in wrapper
    log_failure(e)
  File "C:\Users\ZL\AppData\Local\Programs\Python\Python310\lib\site-packages\pytest_check\check_methods.py", line 304, in log_failure
    (file, line, func, context) = get_full_context(level)
  File "C:\Users\ZL\AppData\Local\Programs\Python\Python310\lib\site-packages\pytest_check\check_methods.py", line 292, in get_full_context
    (_, filename, line, funcname, contextlist) = inspect.stack()[level][0:5]
IndexError: list index out of range

@okken
Copy link
Owner

okken commented Aug 22, 2022

Can you include a full toy example? And full output including Python and pytest version you’re using?

@okken okken reopened this Aug 22, 2022
@okken
Copy link
Owner

okken commented Aug 22, 2022

Sorry. Obvious that you’re using Python 3.10. But what version of pytest? And an example to test with would help.

@zerocen
Copy link

zerocen commented Aug 23, 2022

Python version:3.10.2
Pytest verion:7.1.2

Sorry, I used pytest check in interactive console.

>>> import pytest_check as check
>>> check.greater(1, 2)

When run with pytest, it is fine.

import pytest_check as check
import pytest

cases = [
    (1, 2),
    (2, 2)
]
@pytest.mark.parametrize("a, b", cases)
def test_compare(a, b):
    check.greater(a, b)
    check.less(a, b)
    check.equal(a, b)
    check.not_equal(a, b)

@okken
Copy link
Owner

okken commented Aug 23, 2022

Ah! This helps a ton. I have a fix I think should work. I'll try to get it published this evening.

@okken
Copy link
Owner

okken commented Aug 24, 2022

Could you try this against version 1.0.8?

@okken
Copy link
Owner

okken commented Aug 25, 2022

@zerocen or test with 1.0.9. :)
Also, I'm going to close this, because I'm pretty sure it's fixed.
However, let me know if it's not, and I'll re-open it.

@okken okken closed this as completed Aug 25, 2022
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